When a client was trying to install a script of mine, he got this below error.

Warning: main() [function.main]: open_basedir restriction in effect. File(/script.php) is not within the allowed path(s):

This problem happens mostly on shared networks. The hosting provider would have enabled the ‘open_basedir’ restriction on the server to prevent the user from using php scripts on that particular folder.

In this case, either of the following solutions would work.

1) The host should disable the restriction.
2) Or the host can add the ‘concerned folder path’ to the list of allowed folders.

Once the problem was traced out and fixed, my client was able to install it.

For the hosting providers:

At times, it is needed to restrict file operations for a particular user to their own home or web directories. This can be done easily in PHP by setting the open_basedir variable in PHP.ini. For instance,

open_basedir = /home/website/

will restrict the user to place his files only in this directory. The scripts placed outside won’t run at all. Again, if some user comes to you stating that he gets open_basedir error, you can either reset this variable or ask him to install the product in his restricted directory.

Posted in PHP


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s