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).
Hi
I understand about creating the vhost.conf file, but what do you mean in the above by “save the domain’s configuration via Plesk”.
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.
That has never worked for me. Instead, I have to use this line to get vhost.conf added:
/usr/local/psa/admin/sbin/websrvmng –reconfigure-vhost –vhost-name=domain.com
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…
Kelly,
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)
Hi Brandon,
Thanks for telling me about the DocumentRoot overide. I gave this a go:
DocumentRoot /var/alternate
i.e. that is all that I added to vhost.conf and it worked!
The line to use vhost.conf appears just before in http.include for the relevant virtual host. So it would appear that early entries are over riden by later ones.
*phew*
Things with plesk are not normally that easy!
I agree. It is usually not very easy to do things your own way.
/usr/local/psa/admin/sbin/websrvmng –reconfigure-vhost –vhost-name=domain.com
should be:
/usr/local/psa/admin/sbin/websrvmng -–reconfigure-vhost -–vhost-name=domain.com
Hi,
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.
Hi,
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.
Sorry 😐
@Michael
You can’t have a VirtualHost inside of a VirtualHost (ie: no VirtualHost inside the vhost.conf file).
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.
You saved me so much headache.!!
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
There is a new way of creating vhost.conf file in Plesk 10
You seem to need to create the vhost.conf file first yourself in the same location as before:
/var/www/vhosts/yourdomain.com/conf/
You then need to run this new comand:
/usr/local/psa/admin/sbin/httpdmng –reconfigure-domain yourdomain.com
It takes a while to run so you just have to wait.
Warning: I have only just done it. It seems to work… but I may have missed something.
See also ‘Appendix A: Web Server Configuration Files’ of the ‘Advanced Administration Guide, Parallels Plesk Panel 11.5 for Linux’: http://download1.parallels.com/Plesk/PP11/11.1/Doc/en-US/online/plesk-linux-advanced-administration-guide/index.htm?fileName=68678.htm