How to Fix open_basedir Restriction Error

When you create a staging site with the free WP STAGING plugin, PHP can stop the process with an open_basedir restriction error. The message means PHP is configured to read and write only inside a fixed list of directories, and the folder where WP STAGING wants to build the staging copy is not on that list. The fix is to add your WordPress directory to the open_basedir line in your php.ini file (or your host’s PHP settings) and restart PHP. This guide shows you how to find the file PHP actually loads, edit it safely, and what to check if the error does not go away.

Note: If you try to create a staging site with WP Staging Pro and you get this error while trying to create a default staging site, you can use the advanced setting to create the staging site in a subfolder of ‘wp-content’. Then you can stop reading here.

What the open_basedir restriction error looks like

open_basedir is a PHP security setting that limits file access to an approved list of directories. When any script, including WP STAGING, tries to touch a path outside that list, PHP refuses and logs a warning. In your server or WordPress debug log it typically reads something like this:

Warning: open_basedir restriction in effect.
File(/var/www/html/staging) is not within the allowed path(s):
(/var/www/html/) in /var/www/html/... on line ...

You may also reach this page from a WP STAGING message that mentions it could not include a bootstrap file and lists open_basedir as a possible cause. Both point to the same root problem: the directory WP STAGING needs is outside the allowed paths. The exact file path in your message tells you which directory has to be added to the allowed list.

Why open_basedir blocks WP STAGING

The open_basedir directive is set in the php.ini file and restricts PHP’s file access to the directories you name. By default, WP STAGING creates the staging site in a subdirectory of your WordPress root. If that root, or the subdirectory it wants to write to, is not covered by open_basedir, PHP blocks the write and the staging site cannot be created. Adding the WordPress directory to the allowed list removes the block without turning the security setting off.

How to fix the open_basedir restriction error

To resolve the open_basedir restriction error and successfully create a staging site with WP STAGING, follow these steps in order.

Step 1: Find the php.ini file PHP actually loads

The php.ini file is PHP’s configuration file, and its location varies by hosting environment. A server can have more than one php.ini, so editing the wrong one is the most common reason a fix appears to do nothing. To find the file that is really in effect, create a small file named phpinfo.php in your WordPress root with this content, open it in your browser, and read the value of Loaded Configuration File:

<?php phpinfo(); ?>

If you have shell access, php --ini prints the same path from the command line. Delete the phpinfo.php file once you have the path, because it exposes server details. If you cannot find or edit php.ini at all, skip to the section on hosts without direct php.ini access below.

Step 2: Modify the open_basedir directive

Once you’ve located the php.ini file, you need to edit it to include the directory where you want to create your staging site. Open the php.ini file in a text editor and find the line that starts with open_basedir. You’ll want to add the full path to your WordPress root directory (and its subdirectories) to the existing list. Separate multiple paths with a colon : on Linux or a semicolon ; on Windows.

For example, if your WordPress is installed in /var/www/html/wordpress, and the open_basedir config line in php.ini currently reads:

ShellScript
open_basedir = "/var/www/html/"

You need to modify it to include the WordPress directory:

ShellScript
open_basedir = "/var/www/html/:/var/www/html/wordpress/"

Keep the paths that were already there. Removing an existing path to make room can break other parts of your site that depend on it.

Step 3: Restart your web server or PHP-FPM

After saving changes to your php.ini file, you need to restart PHP for the changes to take effect. If your site runs PHP through Apache’s built-in module, restarting Apache is enough. If it runs on PHP-FPM (common on Nginx and many managed hosts), you also need to restart the PHP-FPM service, not just the web server, or the old configuration stays in memory. Use your hosting control panel or your host’s documentation for the exact restart command.

Step 4: Retry creating your staging site

Once PHP has been restarted, attempt to create your staging site with WP STAGING again. The open_basedir restriction error should now be resolved, allowing the creation process to proceed without issue. To confirm the new setting is live, reload the phpinfo() page from Step 1 and check that the open_basedir value now includes your WordPress directory.

When you cannot edit php.ini directly

On shared and managed hosting you often have no direct access to php.ini. In that case, look for a PHP settings panel in your hosting control panel (for example, a "MultiPHP INI Editor" or "Select PHP Version" screen in cPanel) and set open_basedir there, or ask your host to add your WordPress path to the allowed list for you. If you would rather not touch server settings at all, WP STAGING can build the staging site inside a folder that is already writable, as the note at the top of this article explains.

If the open_basedir error still appears

If the error persists after editing php.ini and restarting PHP, work through these common causes:

  • You edited a php.ini that PHP does not load. Recheck Loaded Configuration File from Step 1 and edit that exact file.
  • You restarted the web server but not PHP-FPM. Restart the PHP-FPM service as well.
  • The path separator is wrong. Use a colon on Linux and a semicolon on Windows, and do not leave a trailing separator with an empty entry.
  • Your host enforces open_basedir centrally and ignores your changes. Contact support and ask them to add the path.
  • As a shortcut, use the WP STAGING advanced setting to create the staging site inside a subfolder of wp-content, which is already writable.

Conclusion

The open_basedir restriction is a security feature that, while important, can sometimes interfere with legitimate operations such as creating a staging environment for your WordPress site. By editing the php.ini file that PHP actually loads, adding your WordPress directory to the allowed list, and restarting PHP, you can clear the error without weakening your server’s security. Always back up your php.ini file before making any changes, and consult with your hosting provider if you are unsure about editing it yourself.

Updated on July 28, 2026

Rene Hermenau

Author: Rene Hermenau

About the author: René Hermenau is the founder of WP STAGING. He works on WordPress backups, staging, migrations, database handling, and safe deployment workflows.