Introduction
This article explains how to add your custom directives to every VirtualHost on the entire server, 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
To apply a change to all HTTP and HTTPS VirtualHosts on the server
- Log in to the server via SSH as the root user.
- Ensure the "userdata" directory exists, then create an include file.
mkdir -pv /etc/apache2/conf.d/userdata/
touch /etc/apache2/conf.d/userdata/include.conf - Add your desired Apache directives to the "include.conf" file.
- Rebuild the Apache configuration:
/scripts/rebuildhttpdconf
- Restart Apache:
/scripts/restartsrv_apache
To apply changes only to all HTTP VirtualHosts
- Log in to the server via SSH as the root user.
- Ensure the "userdata/std" directory exists, then create an include file.
mkdir -pv /etc/apache2/conf.d/userdata/std/
touch /etc/apache2/conf.d/userdata/std/include.conf - Add your desired Apache directives to the "include.conf" file.
- Rebuild the Apache configuration:
/scripts/rebuildhttpdconf
- Restart Apache:
/scripts/restartsrv_apache
To apply changes only to all HTTPS VirtualHosts
- Log in to the server via SSH as the root user.
- Ensure the "userdata/ssl" directory exists, then create an include file.
mkdir -pv /etc/apache2/conf.d/userdata/ssl/
touch /etc/apache2/conf.d/userdata/ssl/include.conf - Add your desired Apache directives to the "include.conf" file.
- Rebuild the Apache configuration:
/scripts/rebuildhttpdconf
- Restart Apache:
/scripts/restartsrv_apache
Additional Resources
If you, instead, only need to modify a single domain's VirtualHost, see the following guide:
How to use Apache Includes to add Configuration Directives to a specific domain's VirtualHost
For more information, please visit our Documentation:
Comments
0 comments
Article is closed for comments.