The volatile Plesk / Apache relationship

Posted on November 4th, 2007 in Linux System Administration by Brandon

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).

13 Responses to 'The volatile Plesk / Apache relationship'

Subscribe to comments with RSS or TrackBack to 'The volatile Plesk / Apache relationship'.

  1. David said,

    on November 27th, 2007 at 8:59 am

    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”.

  2. Brandon said,

    on November 28th, 2007 at 7:15 pm

    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.

  3. Kelly said,

    on April 12th, 2008 at 12:03 am

    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…

  4. Brandon said,

    on April 15th, 2008 at 9:04 pm

    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)

    <VirtualHost *:80>
       ServerName someserver.com
       DocumentRoot /var/www/html
       DocumentRoot /var/alternate
    </VirtualHost>
    
  5. UK Tutor said,

    on April 19th, 2008 at 8:12 am

    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!

  6. Brandon said,

    on April 19th, 2008 at 12:25 pm

    I agree. It is usually not very easy to do things your own way.

  7. sadara said,

    on January 26th, 2009 at 7:57 am

    /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


  8. on January 29th, 2009 at 7:06 am

    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.


  9. on January 29th, 2009 at 7:10 am

    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 :-|

  10. Brandon said,

    on January 29th, 2009 at 7:49 am

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

  11. 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.

    You saved me so much headache.!!

  12. mikosh said,

    on September 16th, 2009 at 3:17 am

    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

  13. UK Tutor said,

    on September 4th, 2011 at 5:15 pm

    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.

Post a comment

Please copy the string EqLVZY to the field below: