Customize httpd.conf for VirtualHost in cPanel

Customize httpd.conf for VirtualHost in cPanel

On cPanel/WHM server, httpd.conf is regularly rebuilt and custom changes are lost each time it is rebuilt. Also, it is not recommended to edit main httpd.conf to change settings for VirtualHost.

WHMCS Complete Billing and Support

To customize httpd.conf for VirtualHost in cPanel, it is required to use include conf file to override any settings.

If you look at the httpd.conf file, you will find with each VirtualHost a notation indicating the file path where your pust custom conf files. Here is the example VirtulHost:
<VirtualHost 173.xx.xx.xx:80>
DocumentRoot /home/useracct/public_html
UseCanonicalName Off
CustomLog /usr/local/apache/domlogs/ combined
CustomLog /usr/local/apache/domlogs/ "%{%s}t %I .\n%{%s}t %O ."
## User useracct # Needed for Cpanel::ApacheConf
<IfModule mod_suphp.c>
suPHP_UserGroup useracct useracct
<IfModule !mod_disable_suexec.c>
SuexecUserGroup useracct useracct
ScriptAlias /cgi-bin/ /home/useracct/public_html/cgi-bin/
# To customize this VirtualHost use an include file at the following location
# Include "/usr/local/apache/conf/userdata/std/2/useracct/*.conf"

At the bottom of this, you will see the location of include file:
Include "/usr/local/apache/conf/userdata/std/2/useracct/*.conf"
In most cases the above folder does not exist hence you will have to create the directory. Now let us if we wish to change defual suPHP_UserGroup for the above VirtualHost, we can create a conf file (let us say custom.conf) inside the following directory:


The contents for custom.conf should be as follow:
<IfModule mod_suphp.c>
suPHP_UserGroup ninety ninety

Once you save your custom configuration file, you will have to run the following commands to include it:

/scripts/ensure_vhost_includes --all-users

Now your default settings will be overridden and you will see that it is loading your custom settings.

Please note that if you have installed SSL certificate on your domain, you will have to create custom conf file on separate location. You will get the location from the SSL VirtualHost entry in your httpd.conf file.

Posted in cPanel.

Leave a Reply

Your email address will not be published. Required fields are marked *