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.

Advertisements