Configure open_basedir for subdomains

Follow the 3 steps to fix open_basedir restriction for subdomains.

We assume that the domain name is $domain.com, the name of the subdomain is $subDomName. You have to replace these values with the appropriate values.

Our goal is to open access to the public website directory and the /tmp directory for the special subdirectory. The directories are mentioned in the php_admin_value open_basedir

Create vhost.conf file for subdomain

Create /srv/www/vhosts/$domain.com/subdomains/$subDomName/conf/vhost.conf with the following content:
<Directory /srv/www/vhosts/$domain.com/subdomains/$subDomName/httpdocs>
<IfModule sapi_apache2.c>
php_admin_flag engine on
php_admin_flag safe_mode off
php_admin_value open_basedir "/srv/www/vhosts/$domain.com/httpdocs:/srv/www/vhosts/$domain.com/subdomains/$subDomName/httpdocs:/tmp"
</IfModule>
<IfModule mod_php5.c>
php_admin_flag engine on
php_admin_flag safe_mode off
php_admin_value open_basedir "/srv/www/vhosts/$domain.com/httpdocs:/srv/www/vhosts/$domain.com/subdomains/$subDomName/httpdocs:/tmp"
</IfModule>
</Directory>

Apply the configuration

The next step is to apply the created configuration and recreate the apache configuration.
Execute the following command on the command line to update the Plesk configuration:
/usr/local/psa/admin/sbin/websrvmng -u --vhost-name=domain.tld

Restart apache

Final and last step is to restart apache:
apache2ctl  restart

That’s all, now your open_basedir restriction is gone.