How to edit all vhost on cpanel

haulpd

Active Member
May 20, 2011
31
1
58
I'm have just install mod_cband for apache. but i can't edit httpd.conf. I want to add config as CBandSpeed, CBanLimit to per host. How to add this config to all vhost on apache ?
anyone helps ?

sorry about my english.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
Hello,

You could add an include at /usr/local/apache/conf/userdata location called cband.conf with the contents you need for all vhosts, then run the following to check the include:

Code:
/scripts/verify_vhost_includes
If it checks out okay, you would then add it after making a backup of Apache's configuration:

Code:
cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.bak110521
/scripts/ensure_vhost_includes --all-users
Finally, you would distill Apache configuration, rebuild Apache configuration, and restart Apache:

Code:
/usr/local/cpanel/bin/apache_conf_distiller --update
/scripts/rebuildhttpdconf
/etc/init.d/httpd restart
Thanks!
 

haulpd

Active Member
May 20, 2011
31
1
58
thank you, but i can't found userdata in /usr/loca/apache/conf/.
i was changed at /var/cpanel/templates/apache1/vhost.default and it update to httpd.conf.
But how to change per vhost without being overwritten by cpanel.
Thanks you.
 
Last edited:

astopy

Well-Known Member
Apr 3, 2003
166
0
166
cPanel Access Level
Root Administrator
If you copy /var/cpanel/templates/apache1/vhost.default to /var/cpanel/templates/apache1/vhost.local you can make changes to vhost.local without them being overwritten by cPanel.

Though, it might be better to use an include in the userdata directory as suggested by Tristan (you can probably just create the directory if it doesn't already exist).
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
You would create the directory if it doesn't exist.

Creating .local files isn't recommended when those are supported, since .local files will ensure the main Apache configuration doesn't get updated when we implement changes. The recommended path would be include files such as how I described.