Plesk’s integration with Apache can be quite confusing for those used to manually modifying the Apache configuration files. It isn’t safe to modify most of the files, because Plesk rewrites them whenever a configuration change is made. Here’s a quick overview of how Plesk fits in with Apache:

The main Apache configuration in /etc/httpd/conf/httpd.conf (or /etc/apache2/apache2.conf on Debian/Ubuntu systems) is left unchanged. It includes /etc/httpd/conf.d/* (or /etc/apache2/conf.d/*). Plesk creates a file in that directory where it does most of its global configuration. That file is generally used for system-wide applications like webmail, mailman, etc. This file is overwritten when certain changes are made via Plesk. It also has an “Include” line for each virtual host like this:

Include /var/www/vhosts/mydomain.com/conf/httpd.include

These files contains the VirtualHost configuration for each domain. They also are overwritten whenever certain changes are made via Plesk (and sometimes just at random, it seems). When Plesk is recreating these files, it looks for a corrosponding ‘vhost.conf’ file in the same ‘conf’ directory. If it finds one, then the resulting httpd.include file Include’s that vhost.conf file. in it.

Therefore, if you want to manually make any changes to the Apache configuration for a website, you need to create a vhost.conf file for it, then re-save the domain’s configuration via plesk.

Also, if you’d like to bypass the whole plesk ordeal for a new domain, you can still create the Apache configuration manually in the original /etc/httpd/conf/httpd.conf file (or /etc/apache2/sites-available/* files).

David, By that, I meant to log into the Plesk web interface and modify something in the domain’s configuration. This will force plesk to recreate the httpd.conf file. At that point it should notice your vhost.conf file, and the httpd.conf file that it creates will Include it.

Out of interest, have you ever tried to change the location of DocumentRoot? Do you think that this could be done with vhost.conf? i.e. do settings set in vhost.conf overwrite settings in httpd.include? I was looking for the answer to this when I found your post. It looks like I’ll have to give it a go tomorrow…

Thanks for that command. I have never tried that before but will certainly try it the next time I have a chance.

I haven’t tried it specifically in Plesk, but I just tried overriding a DocumentRoot via a similar mechanism on a standard Apache 2.0.52 install, and overriding the DocumentRoot via a vhost.conf appears that it would work. I don’t know that it applies to all settings though.

ie: This configuration would have the DocumentRoot as ‘/var/alternate/’ (and not /var/www/html)

thanks for the helpfull informations. If I tried them out the first time I didn’t realize the fact that the vhost.conf was included inside the directive. of my domain and not at the end of the httpd.include file:

… … Include …. /conf/vhost.conf

So I’ve got an error while restarting apache “VirtualHost> inside not allowed” due to the . directive inside my vhost.conf.

thanks for the helpfull informations. If I tried them out the first time I didn’t realize the fact that the vhost.conf was included inside the [VitualHost] directive. of my domain and not at the end of the httpd.include file:

[VirtualHost …. ] … … Include …. /conf/vhost.conf [/VirtualHost]

So I’ve got an error while restarting apache “[VirtualHost] inside [VirtualHost] not allowed” due to the .[VirtualHost] directive inside my vhost.conf.

@Michael You can’t have a VirtualHost inside of a VirtualHost (ie: no VirtualHost inside the vhost.conf file).

Dane said,

on May 15th, 2009 at 12:54 am

THANK YOU SO MUCH.

I was going crazy trying to figure out how to get plesk to see the new vhost.conf file. Restarting apache was not working and you were the online place out of many many websites and several hours of searching that mentioned saving the setup in plesk I would have never thought of that.

thank you so much! you solved my problem too !! i stupidly didn’t see on top of httpd.include what follows:

# ATTENTION! # DO NOT MODIFY THIS FILE OR ANY PART OF IT. THIS CAN RESULT IN IMPROPER PLESK # FUNCTIONING OR FAILURE, CAUSE DAMAGE AND LOSS OF DATA. IF YOU REQUIRE CUSTOM # MODIFICATIONS TO BE APPLIED TO THE CONFIGURATION, PLEASE, PERFORM THEM IN THE # FOLLOWING FILE(S): # /var/www/vhosts/example.com/conf/vhost.conf # /var/www/vhosts/example.com/conf/vhost_ssl.conf # /var/www/vhosts/example.com/subdomains//conf/vhost.conf