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.

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 you can put custom conf files. Here is the example VirtulHost:

<VirtualHost 173.xx.xx.xx:80>
 ServerName your-domain.com
 ServerAlias www.your-domain.com
 DocumentRoot /home/useracct/public_html
 ServerAdmin webmaster@your-domain.com
 UseCanonicalName Off
 CustomLog /usr/local/apache/domlogs/your-domain.com combined
 CustomLog /usr/local/apache/domlogs/your-domain.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
 ## User useracct # Needed for Cpanel::ApacheConf
 <IfModule mod_suphp.c>
 suPHP_UserGroup useracct useracct
 </IfModule>
 <IfModule !mod_disable_suexec.c>
 SuexecUserGroup useracct useracct
 </IfModule>
 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/your-domain.com/*.conf"
 </VirtualHost>

At the bottom of this, you will see the location of include file:

Include "/usr/local/apache/conf/userdata/std/2/useracct/your-domain.com/*.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 default suPHP_UserGroup for the above VirtualHost, we can create a conf file (let us say custom.conf) inside the following directory:

/usr/local/apache/conf/userdata/std/2/useracct/your-domain.com/

The contents for custom.conf should be as follow:

<IfModule mod_suphp.c>
 suPHP_UserGroup ninety ninety
</IfModule>

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

/scripts/verify_vhost_includes
/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.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to top
%d bloggers like this: