WordPress issue causing massive error logs

I have an issue that is causing the error logs to grow massively each day.

[Thu Jan 30 08:55:55 2014] [warn] [client 2.102.44.72] mod_fcgid: stderr: PHP Warning: is_dir(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/var/www/vhosts/inspartnership.org.uk/:/tmp/) in /var/www/vhosts/inspartnership.org.uk/httpdocs/wp-includes/functions.php on line 1366

Read More

(I know that is an old log – but the error hasn’t changed.)

and this is the offending line in WordPress functions.php

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

Now the site functions fine (until the logs get too big and then I get a 500 error) – and I get what is going on to cause the problem – the site is on shared hosting and is trying to access a folder outside of it’s reach – I just don’t know how to fix it and to be honest don’t know where to start!

Has anyone encountered this issue before and can point me in the right direction.

And can anyone help me identify what part of WordPress could be calling this function often enough to make such a massive log

Use simple words – I am being a little bit thick 😀

Thanks in advance

Related posts

Leave a Reply

5 comments

  1. You’re on shared hosting. Hence, you can’t access whole server. As per you log, these are allowed path for your website /var/www/vhosts/inspartnership.org.uk/ /tmp/ and you are trying to access / directory hence causing the issue to occur.

    You can use these wordpress inbuilt functions to resolve this for you.

    For Themes

    http://codex.wordpress.org/Theme_Development#Anatomy_of_a_Theme

    For Plugins

    Plugin Files and Locations

    Few Other Reference Question

    Retrieve WordPress root directory path?

  2. php’s open_basedir is a host configuration; it’s not a bug or an issue with WordPress core.

    1) Get your host to turn php safe_mode off. Running safe_mode on is useless.

    See http://www.php.net/manual/en/features.safe-mode.php

    2) Get the path of the tmp directory from web host. Edit the wp-config.php file and add this line:

    define('WP_TEMP_DIR','../../relative/path/to/tmp');

    3) Find a new host.

  3. Obviously the basepath of $target is “below” the allowed basepath for the user that is running the php instance. According to the logfile, the allowed pathes are “/tmp/” and “/var/www/vhosts/inspartnership.org.uk/”. I assume there is some config missing in your WP installation. Chances are, that it’s just the locaction of the temporary files. Did you move your site recently to another server?
    Just have a look at the settings in “wp-config.php” if they still match the locations of your current server environment.

  4. This can happen when the upload path has been changed to a directory outside of your website’s home directory, I’ve seen it several times; usually when people have added a slash at the beginning of the path. Such a setting may not cause any problems until the path of the home directory in the hosting account is changed, such as when the site is migrated or when the hosting service changes the path.

    It can create huge log files that sometimes will exhaust the disk space on the entire server causing more than one website to fail.

    The upload_path option can be found in Settings -> Media under the label “Store uploads in this folder”. Note: as of version 3.5 the option is hidden unless you already had a non default path (anything other than wp-content/uploads).

    If for any reason you can’t access the WordPress admin but you do have access to the database just remove the value for the upload_path in the wp_options table.

    You can find the row in phpMyAdmin with the query:

    SELECT * FROM `wp_options` where option_name = 'upload_path'
    

    From there, you can click in the option_value field and edit it, then just click outside of the field to save the change.

    screenshot of phpMyAdmin

  5. You may have already resolved the problem, but for future reference I wanted to add this here, since none of the suggested solutions worked for me.

    I was experiencing this same increase of error_log, almost instantly eating up all disc space on my VPS.

    It took a bit of time to find the source of the problem, since it did not occur all the time. In my case, it was not a problem of safe_mode, nor updating wp-config to set a temp directory: the problem was that the WordPress site was originally a blogger site, later on migrated to WordPress. Some of the posts had wp_postmeta rows still referring to the blogger site… These rows contained path’s that we (obviously) were outside the allowed paths. Removing the wp_postmeta rows for the posts that triggered the ‘open_basedir restriction in effect’ errors, resolved the problem, and I have not seen the error since.