badzilla

Member
Mar 3, 2008
19
0
51
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
 

badzilla

Member
Mar 3, 2008
19
0
51
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 ?
 

badzilla

Member
Mar 3, 2008
19
0
51
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 ?
 

badzilla

Member
Mar 3, 2008
19
0
51
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.
 

cPanelKenneth

cPanel Development
Staff member
Apr 7, 2006
4,607
80
458
cPanel Access Level
Root Administrator
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.
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.
 

badzilla

Member
Mar 3, 2008
19
0
51
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 ?
 

cPanelKenneth

cPanel Development
Staff member
Apr 7, 2006
4,607
80
458
cPanel Access Level
Root Administrator
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 ?
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