9th February 2006 - By Aaron Gadberry
Wondering how to create a good vhost.conf? Well you’ve come to the right place.
Plesk automatically updates httpd.include for each domain, making changes to this file only temporary. You don’t want to use this file if you need to make changes to Apache’s config on the fly, such as php’s open_basedir values per domain.
Instead you will want to use a vhost.conf file. This file will be placed inside your domain’s conf directory, usually found at
/var/www/vhosts/yourdomain.com/conf. Create a file called vhost.conf in whatever editor you prefer. I use joe.
You can now put in any Apache configuration options like you would into httpd.include. In my case I wanted to do three things, give my site access to
/php/includes, add a
mod_rewrite rule, and tell Apache to follow symlinks.
Here is my resulting vhost.conf file.
<Directory /var/www/vhosts/yourdomain.com/httpdocs/> php_admin_value open_basedir "/var/www/vhosts/yourdomain.com/httpdocs:/php/includes" </Directory> Options +FollowSymLinks RewriteEngine on RewriteRule /ministries/(.*)\.php$ /ministries/ministry.php?url=$1
You can see the first three lines take care of the additional base directory for php, the line after the empty one takes care of following symlinks, and the last two lines turn on the rewrite engine and add a rule to it.
Save your file and we’re almost done. This is the part that everyone forgets, you need to tell Plesk to update it’s information. See your httpd.include file will soon have an include for your vhost.conf, but it doesn’t yet. Plesk has to realize it’s there and then add the include. The command to reconfigure Plesk for one site is
/usr/local/psa/admin/sbin/websrvmng -u --vhost-name=domain.com or the command I use reconfigures all sites,
After running that there is no need to restart Apache or any other service. Your changes should have taken effect already.
As always, feel free to comment if you have more suggestions or questions.