The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Manually editing httpd.conf despite cPanel recreation/overwriting

Discussion in 'General Discussion' started by Kadence, Nov 23, 2007.

  1. Kadence

    Kadence Member

    Joined:
    Nov 25, 2006
    Messages:
    24
    Likes Received:
    0
    Trophy Points:
    1
    cPanel seems to have a new recent behavior where you're not allowed to manually edit the httpd.conf file, because it recreates it based on cPanel settings. The new httpd.conf has warnings everywhere not to edit it - though this is obviously quite after-the-fact as this new file overrided my original manually edited httpd.conf from about two years ago which didn't have any warnings :(

    I ended up just restoring my old httpd.conf over the new one that cPanel made, because I had a bunch of custom VirtualHost and DocumentRoot settings. The new 'proper' way to edit httpd.conf seems to be using include files, and I'd like to do things this way now just in case this overwriting issue happens again, though I'm not exactly sure how to do this...? Is it as simple as just adding a new entry to httpd.conf like
    Code:
    <VirtualHost xx.xx.xx.xx>
    ServerAlias www.domain.com domain.com
    ServerName www.domain.com
    DocumentRoot /path/to/directory
    User someuser
    Group someuser
    </VirtualHost>
    And then running '/usr/local/cpanel/bin/apache_conf_distiller --update --main'? If I run this with my modified httpd.conf in place will that be OK? (I'm reluctant to experiment for fear of messing things up)

    Previously I would manually add an entry like that and also manually create the zone files, because I wanted to be able to control the VirtualHost IP and DocumentRoot manually, so I added these domains' entries to httpd.conf manually, rather than creating cPanel accounts for them. Never had any difficulties because of it, except for this cPanel re-creating httpd.conf issue.

    Later on that support page it talks about including from a specific .../<user>/... path, but what if the thing that I have custom is the DocumentRoot? Which means there is no /<user>/ path, but a custom one (I had a couple domains that shared a DocumentRoot, so as I said above I added them manually, rather than creating a cPanel account for them).

    Does anyone have any idea how I can customize VirtualHost IP and DocumentRoot, in a way that cPanel would accept when it tries to recreate the httpd.conf file?
     
  2. barwin

    barwin Active Member

    Joined:
    Jan 5, 2004
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Manhattan
    Use the template files

    The httpd.conf file is generated using template files that reside in /var/cpanel/templates/apache2 (or apache1 depending on which Apache version you're running)

    In that directory you'll see files like this:
    main.default
    main.local
    ssl_vhost.default
    vhost.default

    You can customize a file by copying the filename.default to filename.local, and it will be used in preference of the '.default' copy.

    Not every piece of httpd.conf is customizable this way.

    If you prefer to update httpd.conf manually, and then run the command "/usr/local/cpanel/bin/apache_conf_distiller --update", it will actually try to update the "main" template file for you automatically and create the "main.local" file. So in theory you don't need to go copying/editing the 'main.local' file on your own. You can just use the distiller. NOTE: the distiller ONLY works for the 'main' template file though! The others DO require manual editing.

    However, if the update command does NOT create the "main.local" file for you, then that means you were probably updating a part of httpd.conf that is unfortunately not controlled by the template files in /var/cpanel/templates/apache2

    I hope this helps ... I'm still learning the new process myself, but this is what I understand so far. I'm basically paraphrasing the information found at the top of the new httpd.conf that was installed by easy apache 3 in cpanel11:

    Good luck!

    Ben Arwin
     
  3. tenaciousJ

    tenaciousJ Member

    Joined:
    Dec 18, 2003
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    I'm just wondering why this new convoluted system is in place.

    Our system was recently updated, the previous httpd.conf (1.3) was completely overwritten and no additional backups were made (although there were 5 different 2.2 now in place).

    Now, to make the simplest changes you seem to have to go around your #@%! to get to your elbow. How are the above steps any simpler than: edit httpd.conf, add entry, save. All the info is in one place. Now depending on the type of entry it could be in one of several places.

    I'm just ranting really i guess. I'm sure there is a logical reason for the way things being changed to the way they are, but i wish there was at some way to allow for old style editing.
     
Loading...

Share This Page