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.

Help - how to edit httpd.conf

Discussion in 'General Discussion' started by badzilla, Mar 3, 2008.

  1. badzilla

    badzilla Member

    Joined:
    Mar 3, 2008
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    1
    I got a VPS running Apache 2.2. I understand most of the httpd.conf configuration, but I simply don't understand how to edit it correctly, so whm can rebuild the config without removing my changes.

    First simple problem is, that I do not want customized errorpages, so I don't want this:

    Code:
    ErrorDocument 400 /400.shtml
    ErrorDocument 401 /401.shtml
    ErrorDocument 403 /403.shtml
    ErrorDocument 404 /404.shtml
    ErrorDocument 500 /500.shtml
    I can see it is generated from this part of the template:

    Code:
    [% FOREACH dir IN main.errordocument.items -%]
    ErrorDocument [% dir.code %] [% dir.document %]
    [% END -%]
    
    but where does main.errordocument.items come from and how do I change it ?


    Another problem is that I got 4 IP's (lets call them IP1 - IP4), and only IP4 is the shared, but I still get this:

    Code:
    NameVirtualHost *:80
    NameVirtualHost <IP1>:80
    NameVirtualHost <IP4>:80
    NameVirtualHost *
    Unless I don't understand NameVirtualHost, this looks wrong to me.


    I got a few more problems, but if someone can help me with these, mayby I can figure out the rest.

    Thanks for any help, I really appreciate it.

    Michael
     
  2. badzilla

    badzilla Member

    Joined:
    Mar 3, 2008
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    1
    Okay, I figured out where the errordocuments are defined, but I don't think I want to edit that file.

    So the main question must be, is it safe to edit

    Code:
    /var/cpanel/templates/apache2/main.default
    or is there any risk that this file will be restored during the nightly automatic updates ?
     
  3. viraj

    viraj Well-Known Member

    Joined:
    Sep 28, 2006
    Messages:
    209
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    India
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    Hi,

    There's no risk in getting the file updated as per your requirement, but I'd recommend you to backup the original file as main.default_bak in a different dir & to also chattr +aui the main.default file, this will make the file unwritable for any scripts.
     
  4. badzilla

    badzilla Member

    Joined:
    Mar 3, 2008
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    1
    Thanks. I will probably end up doing that.

    But I'm still interested to know, if there is a right way to do it. I mean, the information about the errorpages are located in a file (don't remember the location, but it is just called main), but there is no GUI interface in WHM to change these options, and not really much information about the file and if it is safe to edit.

    Oh, why have they made it so difficult to edit httpd.conf in apache2 ?
     
  5. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,474
    Likes Received:
    202
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
  6. viraj

    viraj Well-Known Member

    Joined:
    Sep 28, 2006
    Messages:
    209
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    India
    cPanel Access Level:
    DataCenter Provider
    Twitter:
  7. badzilla

    badzilla Member

    Joined:
    Mar 3, 2008
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    1
    Most of them, but read the overview again. And learned a little bit more.

    As far as I understand a new apache build will do this:

    - Parse the current httpd.conf, and save data in datastore
    - Overwrite the httpd.conf with a default from the installation
    - Make a new template based on the newly installed httpd.conf
    - Use the new template and datastore to build a new httpd.conf


    If so, it sorts of makes sense. And in that case, I should rather be editing the datastore, instead of the template.

    I have tried to remove the errrordocuments from httpd.conf, and run the distiller. and the for-loop in the template was removed, but the datastore still had the entries. Maybe I should just insert 'default' as errordocument instead, and run the distiller, and hopefully the datastore would be updated with this value.

    However, I also tried to remove all NAMEVIRTUALHOST except one, but after running the distiller and rebuilding the configuration, all 4 NAMEVIRTUALHOST was back, so that is a problem.
     
  8. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,461
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Do not mark the template as immutable.

    Use the Reserved IPs editor in WHM -> Service Configuration -> Apache Setup to deselect the IP addresses you don't want Apache to use.

    If you want to customize the template, rename it to the .local variant, it will be used in lieu of the .default version. Example:

    Code:
    cp main.default main.local
    
    Make your changes to main.local. Next time httpd.conf is rebuild (manually or via easyapache), main.local will be used and main.default will be ignored.


    Editing the datastore is not recommended as that data is volatile. Instead, fix the source of the problem and regenerate the datastore.
     
  9. badzilla

    badzilla Member

    Joined:
    Mar 3, 2008
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    1
    Thanks. I overlooked that main.local could be used.

    If I rebuild Apache, which also creates a new main.default, will main.local be deleted, or will it still be used for building the new httpd.conf after the apache-build ?
     
  10. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,461
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    cPanel will not delete main.local (or any of the other .local variants). At all times, main.local will be used in lieu of main.default when (re)building httpd.conf
     
Loading...

Share This Page