Tips: Custom Configurations of httpd.conf on WHM/CPANEL server

Here are the two common situations of adding custom changes:

Changes added inside a

1
<VirtualHost>

This is very simple as we only need to create a single file that will contain our changes. But we need to understand the correct location on where to place this file so that our changes will be read properly.

There are several cases of adding these changes and below are some samples and the coresponding directory where to put them:

  • One virtualhosts (either SSL or standard)

Apache1/SSL:

1
/usr/local/apache/conf/userdata/ssl/1/<cpanel_user>/<domain>/<filename>.conf

Apache1/Standard:

1
/usr/local/apache/conf/userdata/std/1/<cpanel_user>/<domain>/<filename>.conf

Apache2/SSL:

1
/usr/local/apache/conf/userdata/ssl/2/<cpanel_user>/<domain>/<filename>.conf

Apache2/SSL:

1
/usr/local/apache/conf/userdata/std/2/<cpanel_user>/<domain>/<filename>.conf

  • All virtualhosts (both SSL and standard)

1
Apache 1/2:   /usr/local/apache/conf/userdata/<something>.conf

  • All SSL virtualhost or all Standard virtualhost

Apache 1/2 – all SSL:

1
/usr/local/apache/conf/userdata/ssl/<filename>.conf

Apache 1/2 – all Standard:

1
/usr/local/apache/conf/userdata/std/<filename>.conf

  • If you need to put the above changes on a specific Apache version you can put them this way:

Apache 1 – all SSL:

1
/usr/local/apache/conf/userdata/ssl/1/<filename>.conf

Apache 2 – all Standard:

1
/usr/local/apache/conf/userdata/std/2/<filename>.conf

The same process is followed on subdomains, like on one of my implementation i added a custom virtualhost in a subdomain to take effect on standard (http), so i put it on this directory:

1
/usr/local/apache/conf/userdata/ssl/2/gerold/mysubdomain.gerold.com/custom.conf

Take note that you also need to create the directories like ssl, std, 1, 2, or mysubdomain.gerold.com” in order to have the correct directory structure/path.

You can verify if your custom changes were added correctly using this command:

1

1
<span class='line'>/scripts/verify_vhost_includes</span>

Then, update the include files:

For changes concerning single account/user you can use this command:

1

1
<span class='line'>/scripts/ensure_vhost_includes --user=&lt;username&gt;</span>

And for all users run:

1

1
<span class='line'>/scripts/ensure_vhost_includes --all-users</span>

And finally, restart Apache (

1
/etc/init.d/httpd restart

)

Changes added outside a

1
&lt;VirtualHost&gt;

Adding custom changes outside of virtualhost can be done in different ways, like creating a templates or using the include editor.
On my example, i will discuss using Include editor as i usually used this on some of our client sites.

Cpanel have three ways to place our custom changes using Include editor, these are:

  • Pre-Main Include – this is placed at the top of the httpd.conf file
    Location:

    1
    /etc/httpd/conf/includes/pre_main_1.conf
  • Pre-VirtualHost Include – codes in this file are added before the first Vhost configuration
    Location:

    1
    /etc/httpd/conf/includes/pre_virtualhost_1.conf
  • Post-VirtualHost Include – codes in this file are added at the end of httpd.conf
    Location:

    1
    /etc/httpd/conf/includes/post_virtualhost_1.conf

So to add our changes we can go to WHM:

1
Main &gt;&gt; Service Configuration &gt;&gt; Apache Setup &gt;&gt; Include Editor

, and select where you want to place your custom changes (pre-main, pre-vhost, or post-vhost).
You can also edit directly the files (pre_main_1.conf, pre_virtualhost_1.conf, post_virtualhost_1.conf) located at

1
/etc/httpd/conf/includes/

.
Finally, restart Apache (

1
/etc/init.d/httpd restart

) for changes to take effect.

NOTE: For complete referrence please refer to Cpanel Docs.

Scroll to top