Introduction
This article explains how to add your custom directives to a single domain's VirtualHost, inside the VirtualHost context.
Apache configuration directives have certain contexts associated with them. The contexts that are associated with a directive determine where a directive can exist. For more information about Apache's Contexts, please see their documentation:
Contexts | Apache Documentation
There are some Apache directives that need to be set within the VirtualHost context. If you need to add a directive to the VirtualHost context, you would need to use the method described in this article to do so.
Procedure
You'll need root access, either via SSH or WHM / Server Configuration / Terminal in WHM, to complete this task.
- Log in to the server via SSH as the
rootuser, or log into WHM asrootand navigate to WHM / Server Configuration / Terminal in WHM.
CPANEL_WARN: For the commands below, replace $cpanelusername with the cPanel account username that holds the domain, and domain.tld with the domain name that you wish to add the custom configuration for.
-
Create the folders to hold your custom include files:
# mkdir -p /etc/apache2/conf.d/userdata/ssl/2_4/$cpaneuser/domain.tld/
# mkdir -p /etc/apache2/conf.d/userdata/std/2_4/$cpaneuser/domain.tld/
-
Create the include files themselves:
# touch /etc/apache2/conf.d/userdata/ssl/2_4/$cpaneuser/domain.tld/include.conf
# touch /etc/apache2/conf.d/userdata/std/2_4/$cpaneuser/domain.tld/include.conf
CPANEL_INFO: The "include" in "include.conf" can be changed, but the files are loaded in alphabetical order.
- Using your preferred text editor, edit the newly created .conf files so they contain your desired directives.
-
Rebuild the Apache configuration to add the includes with this command:
# /usr/local/cpanel/scripts/rebuildhttpdconf
-
Restart Apache so it reads the new configuration:
# /usr/local/cpanel/scripts/restartsrv_httpd
Additional Resources
If you, instead, need to modify all VirtualHosts, see the following guide:
How to use Apache includes to add configuration directives to all VirtualHosts server-wide
For more information, please visit our Documentation:
Comments
0 comments
Article is closed for comments.