When moving from Ensim to Plesk I noticed that all my PHP programs stopped working. Every relative pathed file I had added to a require() statement error'ed with the message:
open_basedir restriction in effect
I added the current directory ('.') to PHP's include_path
but it didn't make any difference. After an awful lot of trial and error I worked out that the include_path
was being ignored and the open_basedir
was being used instead. This is different from the PHP documentation.
The PHP configuration has this whole idea of **Local Value** and **Master Value** and unfortunately they do not inherit. If the **Local Value** is specified and it does not include any of the **Master Value**'s then those **Master Value**s will not be counted (and vice-versa). Bummer, because Plesk specifies the open_basedir
in the configuration specific file for each domain. Double bummer because every time you change a configuration option for your domain Plesk overwrites these configuration files, so it means that any changes that you make in there will be lost.
Luckily, Plesk have built in some protection to allow users of virtual hosts to use site specific options for PHP and/or Apache.
Apache's domain specific configuration file for your domain is located in:
/var/www/vhosts/your.domain/conf/httpd.include
It contains a line to include another virtual host's specific file. In here we can add the voodoo to take away our require / open_basedir problem by including the current directory in the search path.
Go to the conf
directory and create a file called vhost.conf
. Use your favourite editor (and if that is not vi or notepad2, you ought to be ashamed of yourself!) to add the following contents:
php_admin_flag engine on
php_admin_flag safe_mode on
php_admin_value open_basedir "/var/www/vhosts/example.com/httpdocs:.:/php:/tmp"
php_admin_flag engine on
php_admin_flag safe_mode on
php_admin_value open_basedir "/var/www/vhosts/example.com/httpdocs:.:/php:/tmp"
The new open_basedir
contains:
/var/www/vhosts/your.domain/httpdocs
and /tmp
because they where in the **Master Value**.
.
for the current directory which solves my relative path problems.
/php
because it contains all the PHP functions which are common to more than one domain. There is another problem with Plesk, **Safe Mode**, shared include path directories and user permissions, but that's a blog for another time! If anyone asks nicely then, I'll write it up.
After making the changes restart the web server, and all should be well.