Configure open_basedir for subdomains

Follow the 3 steps to fix open_basedir restriction for subdomains.

We assume that the domain name is $, 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/$$subDomName/conf/vhost.conf with the following content:
<Directory /srv/www/vhosts/$$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/$$$subDomName/httpdocs:/tmp"
<IfModule mod_php5.c>
php_admin_flag engine on
php_admin_flag safe_mode off
php_admin_value open_basedir "/srv/www/vhosts/$$$subDomName/httpdocs:/tmp"

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.

Subdomain working as catch-all

In this article you’ll learn to configure Plesk that it uses one subdomain as catch-all for all non-existing subdomains.

Why you would need catch all subdomains

Maybe you have a few subdomains. But sometimes your visitors are accessing non-existing subdomains. So the best solution would be to either redirect them to your main website or at least show them a list of available pages.
Here comes the catch-all subdomain : There you can either configure Apache that it redirects all accesses to the main webpage (via 301, as written e.g. in this article Migrate domain names with .htaccess ) or just have a static (or dynamic, of course) page displayed to the user.

Step-by-step configuration

  1. Create a subdomain z-WILDCARD in Plesk – of course in the admin section of the right domain.
    Why do we need this name? ’cause this entry should be the last entry in the list of subdomains, otherwise this “trick” will not work. So if you have a domain as e.g. zabalula , than you should maybe name the subdomain zzzz-WILDCARD or similar.
  2. Add special configuration (catchall for all subdomains) to the vhosts.conf file of this subdomain.
    Normally it’s located in /srv/www/vhosts/ You have to create it – normally you need the root user to do this. Copy the following content into the file:
    ServerAlias *
  3. Apply the new configuration – recreate the Apache configuration. You have to run the tool websrvmng which is a Plesk tool that manages and creates the webserver configuration. Execute the following as root user.
    /usr/local/psa/admin/sbin/websrvmng -u
  4. Finally – restart Apache to load the new configuration, also as root.
    apache2ctl restart

That’s it – now you can try accessing non-existing subdomains as e.g. and you should see the Plesk page displayed for new pages. Next step would be to e.g. add the 301 redirect or use a custom page.

Note: This has been tested with Plesk 8 and Suse Linux. Please leave a comment if this also works on other version of Plesk / linux – or something did not work.