How to Fix the WordPress Warning: open_basedir restriction in effect Issue?

How to Fix the WordPress Warning: open_basedir restriction in effect Issue?

In some cases, you’ll notice that some users are unable to access a certain file or folder. The error message you get is the “open_basedir restriction in effect.” If you’re experiencing this error and looking for a quick resolution, this article is for you. Here we explain how to fix this issue at the earliest.

What this issue is all about?

The WordPress system throws the open_basedir restriction error when a user tries to access files and folders that he is not supposed to. These files belong to another user. Thus, you can conclude this is a security restriction.

You get the following messages when trying to visit a directory or file:
  • open_basedir restriction in effect. File(/tmp) is not within the allowed path(s).
  • Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/home/some/path/here/) is not within the allowed path(s).
  • Warning: is_writable() [function.is-writable]: open_basedir restriction in effect.
File(/) is not within the allowed path(s).

So WordPress prevents you from using the webserver.

Let’s understand it considering an example. Suppose a function within a WordPress theme or plugin tries to access a folder outside of the home directory. In such cases, it doesn’t have the necessary privileges to do so. So the WordPress system will throw an error.

There are multiple ways to fix this error. You can either ease the security restrictions or debug the code of the WP theme/plugin. In either case, it will resolve the error.

Fixing open_basedir restriction Error

As already said, there are a couple of ways of fixing this error.

Here’s the steps involved in the first way:
  • Open the web-config file using FTP. Then add the following line of code into the file where you replace the mydomain with your domain name:
Code:
DEFINE(‘WP_HOME’,’HTTP://MYDOMAIN.COM’);
DEFINE(‘WP_SITEURL’,’HTTP://MYDOMAIN.COM’);
  • Create a new wp-content folder using FTP or Panel access. Give it a name and allow writing rights.
  • Navigate into admin panel >> Settings >> Media. Here you’d have to change the path of uploading files to the new directory you just created.
wordpress.png

  • If that doesn’t work, create a new .htaccess file and replace old files with new ones.
That should fix the error.

Disable PHP open_basedir Restriction

The other way to fix this error is to edit the Apache configuration file. This is recommended for those admins who lack cPanel WHM, or Plesk on VPS hosting.

Here are the steps involved:
  • Open the httpd.conf file and look for this line - “php_admin_value open_basedir some_value_here
  • Then replace it with “php_admin_value open_basedir none
You’d want to achieve other things as well. For example, you can allow PHP scripts of other user account to access directories that are outside of the scope of home directory. For this, you’d have to add the following code to the file:

Code:
php_admin_value open_basedir “/home/user_account/:/usr/local/lib/php:/tmp:/new_directory”
You can add multiple directories by separating them with a colon on Linux or Unix server. For Windows server, it’s a semicolon.

Then restart the Apache server after you’ve finished making the changes.

You may want to add a trailing slash as like the /dir/incl/. This will ensure /dir/incl will match with /dir/includes.

So that’s how to fix this error. For further assistance, contact your hosting provider.
Author
kumkumsharma
Views
23,977
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from kumkumsharma

Top