Plesk configuration - get open_basedir working for a subdomain

Learn how to remove the open base dir restriction for a special directory that Plesk automatically creates for subdomains.

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
  1. Create a special vhost.conf file for the 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>
  2. 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
  3. Final and last step is to restart apache
    apache2ctl  restart
That's all, now your open_basedir restriction is gone away.

Google Adsense