Customizing Apache config with Plesk

Recently, I’ve had to customize some Apache configuration options on one of my servers running Plesk. I needed to modify PHP’s open_basedir parameter among other things, and it was a little tricky to figure out how to do it properly. Once I figured it out, I thought I’d share.

FYI, I’m running Plesk 10.4.

Plesk allows you to add your own configuration files for each domain, vhost.conf and vhost_ssl.conf. The location of these files varies depending on if you’re using a regular domain or a subdomain. The locations are:

/var/www/vhosts/domain.tld/conf/vhost.conf
/var/www/vhosts/domain.tld/subdomains/<somesubdomain>/conf/vhost.conf

The format of these files should look something like this:

<Directory /var/www/vhosts/domain.tld/<subdomainlocation>>
  ServerAdmin  "[email protected]"
  <IfModule mod_php5.c>
    php_admin_value open_basedir /var/www/vhosts/domain.tld/:/tmp/:/opt/php/lib/php
  </IfModule>
  <IfModule sapi_apache2.c>
    php_admin_value open_basedir /var/www/vhosts/domain.tld/:/tmp/:/opt/php/lib/php
  </IfModule>
</Directory>

I added a few extra options as an example. If I were modifying my main domain, the config would look like this:

<Directory /var/www/vhosts/brandonwamboldt.ca/httpdocs>
  ServerAdmin  "[email protected]"
  <IfModule mod_php5.c>
    php_admin_value open_basedir /var/www/vhosts/brandonwamboldt.ca/:/tmp/:/opt/php/lib/php
  </IfModule>
  <IfModule sapi_apache2.c>
    php_admin_value open_basedir /var/www/vhosts/brandonwamboldt.ca/:/tmp/:/opt/php/lib/php
  </IfModule>
</Directory>

Next step is to modify the permissions on your new config files.

chown root:apache vhost.conf
chmod 640 vhost.conf

And finally, ask plesk to reconfigure it’s configuration to include this new config:

/usr/local/psa/admin/sbin/httpdmng --reconfigure-domain brandonwamboldt.ca

Note: Even if you’re adding a config file for a subdomain, you must reconfigure the top level domain

Leave a Reply