Warning: is_dir(): open_basedir restriction in effect. File(/) is not within the allowed path(s)

Tijmen picture Tijmen · Jun 24, 2016 · Viewed 15.2k times · Source

EDIT: This is not a duplicate of open_basedir restriction in effect. File(/) is not within the allowed path(s):. This issue has nothing to do with the PHP settings, as I have several websites working under the same map structure and the same PHP settings. Please read the entire question before labelling it as a duplicate, as I have explained this in the final 4 paragraphs of this question. In addition, the answers in that other question are geared toward Apache, whereas I'm using Nginx, which does not use CPanel or httpd.conf.

I've manually moved my Wordpress sites to a new server. For the last one, I'm getting this error:

  Warning: is_dir(): open_basedir restriction in effect. File(/) is not
  within the allowed path(s):
    (/var/hpwsites/u_bcsautoborg:/usr/share/pear/) in 
    /var/hpwsites/u_bcsautoborg/website/html/webroot/wp-includes/functions.php on
 line 1585

I had a similar error with the site before, but that was due to the upload folder not being linked to correctly from the Wordpress settings. Thus, the error showed a different line number.

Line 1585 is:

while ( '.' != $target_parent && ! is_dir( $target_parent ) ) {

and is part of the larger block:

/*
     * Safe mode fails with a trailing slash under certain PHP versions.
     * Use rtrim() instead of untrailingslashit to avoid formatting.php dependency.
     */
$target = rtrim($target, '/');
if ( empty($target) )
    $target = '/';

if ( file_exists( $target ) )
    return @is_dir( $target );

// We need to find the permissions of the parent folder that exists


and inherit that.
    $target_parent = dirname( $target );
    while ( '.' != $target_parent && ! is_dir( $target_parent ) ) {
        $target_parent = dirname( $target_parent );
}

This is from a Wordpress functions file. Going from the code, I'd assume the issue is with $target_parent, but I don't know what that refers to, as I'm not very good with PHP.

Now I know an open_basedir restriction error generally means the PHP.ini file has incorrect security settings, which do not allow the PHP function to access the required folder. However, I'm certain that isn't the case here.

This was a working website, built around the same structure as all my other sites. All were hosted on an Apache server, and I'm moving to an Nginx server, and all have a directory of their own, with their own MySQL database, and all directories contain the same files and folders (apart from the website-specific folders of course). All other websites work perfectly in the same setup as this, and as such I can't imagine this being a php.ini issue.

In the previous case, where the issue was with the 'uploads' folder, I was still able to get into wp-admin and change the uploads folder location through the Wordpress settings. However, I'm unable to get into any page now, as I only get the above error, which duplicates to infinity.

I've disabled all plugins through PHPmyAdmin, but to no avail. Obviously, I've looked for a solution on SO, wordpress forums, Google and DuckDuckGo. I've found many similar issues, but none of the solutions I found worked for me.

Does anybody have any idea where the cause might be?

Answer

Linn picture Linn · Jun 26, 2017

I had the same issue and came across this via a Google search. @hicham's comment above got me on the right track, here's how I was able to fix it in case others are looking. I edited the database via phpMyAdmin as follows:

  1. Click on the wp_options table
  2. Click Search, and enter "upload_path" in the "option_name" field
  3. This should return one row with your old host's path as the "option_value". Double-click the value to edit, and change it to the path of the "uploads" folder at your new host (you should be able to figure it out via FTP or your host's control panel).