I get an "open_basedir" error in PHP script. How can I fix it ?
This error means that PHP script tries to access a folder access to which is not allowed. For security reasons, PHP options for domains hosted in Parallels Plesk Panel allow access to /tmp and http(s)docs folders only by default. Restrictions are limited by open_basedir PHP variable for each virtual host separately.
In case you need to allow access with PHP scripts of a certain virtual host to additional folder(s), you should set up option 'open_basedir' for the virtual host with the new path value, splitting the folder names with colons. This action can only be made by a user with root privileges on domains’ vhost.conf or vhost_ssl.conf files (for SSL virtual host). For more information, read the article 'Including Directives into Configuration File of Web Serve' in the Parallels Plesk Panel documentation.
Once applied these changes, you should recreate Apache’s configuration files and restart Apache service using the following command in the shell. If the vhost(_ssl).conf file is found, then it will be automatically added to the httpd.include file of the domain:
~# /usr/local/psa/admin/sbin/websrvmng -a -v
NOTE: If do not run the command above vhost.conf or vhost_ssl.conf would not be included to Apache configuration and the changes not take affect.
NOTE: HTTPD_VHOSTS_D needs to be replaced by a real path to the domain location, which may vary according to the OS and Parallels Plesk Panel version. You can look up the current value in the /etc/psa/psa.conf file. ADD_PATH needs to be replaced by a real path to the folder we are granting access to.
php_admin_value open_basedir HTTPD_VHOSTS_D/domain.com/httpdocs:/tmp:/ADD_PATH
php_admin_value open_basedir HTTPD_VHOSTS_D/domain.com/httpsdocs:/tmp:/ADD_PATH
For subdomains, create the corresponding HTTPD_VHOSTS_D/domain.tld/subdomains/subdomain/conf/vhost.conf file:
php_admin_value open_basedir "HTTPD_VHOSTS_D/domain.com/subdomains/subdomain/httpdocs:/tmp:/ADD_PATH"
Also, you can set up global 'open_basedir' for a certain location required in /etc/php.ini, for example:
open_basedir = "/tmp"
Once php.ini changed, restart Apache.