My manual changes was not conserver in httpd.conf

postcd

Well-Known Member
Oct 22, 2010
717
19
68
I had an instruction to add some ifmodule directive into httpd.conf .

But appears this change was not reflected after i did:

/usr/local/cpanel/bin/apache_conf_distiller --update

and then

/usr/local/cpanel/bin/build_apache_conf

Please how the easiest way i can modiffy this httpd.conf from A) command line, B) WHM and keep changes 4ever?


This is httpd.conf header:

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Direct modifications to the Apache configuration file may be lost upon subsequent regeneration of the #
# configuration file. To have modifications retained, all modifications must be checked into the #
# configuration system by running: #
# /usr/local/cpanel/bin/apache_conf_distiller --update #
# To see if your changes will be conserved, regenerate the Apache configuration file by running: #
# /usr/local/cpanel/bin/build_apache_conf #
# and check the configuration file for your alterations. If your changes have been ignored, then they will #
# need to be added directly to their respective template files. #
# #
# It is also possible to add custom directives to the various "Include" files loaded by this httpd.conf #
# For detailed instructions on using Include files and the apache_conf_distiller with the new configuration #
# system refer to the documentation at: EasyApache #
# #
# This configuration file was built from the following templates: #
# /var/cpanel/templates/apache2/main.default #
# /var/cpanel/templates/apache2/main.local #
# /var/cpanel/templates/apache2/vhost.default #
# /var/cpanel/templates/apache2/vhost.local #
# /var/cpanel/templates/apache2/ssl_vhost.default #
# /var/cpanel/templates/apache2/ssl_vhost.local #
# #
# Templates with the '.local' extension will be preferred over templates with the '.default' extension. #
# The only template updated by the apache_conf_distiller is main.default. #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
 
Last edited by a moderator:

postcd

Well-Known Member
Oct 22, 2010
717
19
68
i read the docs, but im unsure where should i put my directive

<IfModule mod_evasive20.c>
DOSHashTableSize 3097
DOSPageCount 2
DOSSiteCount 50
DOSPageInterval 1
DOSSiteInterval 1
DOSBlockingPeriod 60
DOSEmailNotify [email protected]
</IfModule>
to be preserved. it is Mod evasive. I have default Apache WHM/cpanel server setup which i installed before one week, Optimised license
 

JaredR.

Well-Known Member
Feb 25, 2010
1,834
23
143
Houston, TX
cPanel Access Level
Root Administrator
Do your manual changes need to go inside a VirtualHost container, or outside a VirtualHost container? That is the first thing you need to establish, and that is why I asked that question in my previous reply. If you are not sure if the changes need to be inside or outside a VirtualHost container, you should ask the developer of the software you are trying to install.

Once you know whether they should go inside or outside a VirtualHost container, the documentation explains how to make custom changes for each scenario.
 

postcd

Well-Known Member
Oct 22, 2010
717
19
68
Developer i think dont mention if virtual host or not virtual host. But i found:

Q.

But if I do it in cPanel/WHM do I need to insert it in the "Pre VirtualHost Include" in Apache Configuration?
A.
That is really a matter of choice.
I myself inserted it on a lot of servers just before the <Directory /> section
in the main httpd.conf file at /usr/local/apache/bin and ran the update script

Another quotation:
The module directives should be written only inside httpd.conf file (per VirtualHost configuration is also supported).
does it make more sense where to add it? I want to use this module for all cpanel accounts. So in which file and where to add it please?
 

postcd

Well-Known Member
Oct 22, 2010
717
19
68
so on "Home »Server Status »Apache Status" i see "Server Version: Apache/2.2.27 (Unix)".

ls -l /var/cpanel/templates
total 24
drwxr-xr-x 6 root root 4096 Apr 20 11:23 ./
drwxr-xr-x 83 root root 4096 Apr 23 12:39 ../
drwxr-xr-x 2 root root 4096 Apr 20 11:23 apache1/
lrwxrwxrwx 1 root root 29 Apr 20 11:23 apache1_3 -> /var/cpanel/templates/apache1/
drwxr-xr-x 2 root root 4096 Apr 23 05:39 apache2/
lrwxrwxrwx 1 root root 29 Apr 20 11:23 apache2_0 -> /var/cpanel/templates/apache2/
lrwxrwxrwx 1 root root 29 Apr 20 11:23 apache2_2 -> /var/cpanel/templates/apache2/
drwxr-xr-x 2 root root 4096 Apr 20 11:23 apache2_4/
drwxr-xr-x 2 root root 4096 Apr 20 10:51 dovecot2.2/
so i assume i need to edit in apache2 directory ONLY?..

ls -l /var/cpanel/templates/apache2
total 64
drwxr-xr-x 2 root root 4096 Apr 23 05:39 ./
drwxr-xr-x 6 root root 4096 Apr 20 11:23 ../
-rw-r--r-- 1 root root 23684 Apr 23 05:39 main.default
-rw-r--r-- 1 root root 7576 Apr 23 05:39 ssl_vhost.default
-rw-r--r-- 1 root root 7576 Apr 20 17:36 ssl_vhost.local
-rw-r--r-- 1 root root 6940 Apr 23 05:39 vhost.default
-rw-r--r-- 1 root root 6940 Apr 20 17:36 vhost.local

but vhost.local and ssl:vhost.local is already existing and it contains alot of data. Im unsure where exactly i need to add my rule mentioned in third post of this topic?

head vhost.local

<VirtualHost[% FOREACH ipblock IN vhost.ips %] [% ipblock.ip %]:[% ipblock.port %][% END %]>
ServerName [% wildcard_safe(vhost.servername) %]
[% IF vhost.serveralias_array.size -%]
[% FOREACH alias IN vhost.serveralias_array -%]
ServerAlias [% alias %]
[% END -%]
[% ELSE -%]
ServerAlias [% vhost.serveralias %]
[% END -%]
hope you can advice, help
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,241
363
You can use an include file. EX:

Code:
vi /usr/local/apache/conf/userdata/mod_evasive.conf
Add the custom entry you referenced earlier to this file. Save the file, then run:

Code:
/scripts/verify_vhost_includes
Then, assuming it does not fail, rebuild the Apache configuration file via:

Code:
/scripts/rebuildhttpdconf
This adds the entry to all Virtual Hosts, regardless of Apache version.

Thank you.