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 the WHM Terminal to complete this task.
- Log in to the server via SSH as the root user, or log into WHM as root and navigate to Terminal.
- Issue the following commands, replacing CPANELUSERNAME and DOMAIN.TLD as appropriate for your situation. Additionally, the "include" in "include.conf" can be changed, but the files are loaded in alphabetical order. The username and domain portion are in all capital letters in this example to highlight what needs to be changed, but make sure to use all lowercase letters when running the commands on your server:
mkdir -p /etc/apache2/conf.d/userdata/ssl/2_4/CPANELUSERNAME/DOMAIN.TLD/
mkdir -p /etc/apache2/conf.d/userdata/std/2_4/CPANELUSERNAME/DOMAIN.TLD/
touch /etc/apache2/conf.d/userdata/ssl/2_4/CPANELUSERNAME/DOMAIN.TLD/include.conf
touch /etc/apache2/conf.d/userdata/std/2_4/CPANELUSERNAME/DOMAIN.TLD/include.conf - Edit the newly created 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.