Question
How do you use Apache includes to add configuration directives to all VirtualHosts server-wide?
Answer
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.
- Log in to the server via SSH or WHM's Terminal as the
rootuser -
Ensure the "userdata" directory exists, then create an include file:
# mkdir -pv /etc/apache2/conf.d/userdata/; touch -v /etc/apache2/conf.d/userdata/include.conf
- Add your desired Apache directives to the newly created
/etc/apache2/conf.d/userdata/include.conffile. -
Rebuild the Apache configuration:
# /scripts/rebuildhttpdconf
-
Restart Apache:
# /scripts/restartsrv_apache
- Log in to the server via SSH or WHM's Terminal as the
rootuser -
Ensure the "userdata/std" directory exists, then create an include file:
# mkdir -pv /etc/apache2/conf.d/userdata/std/; touch -v /etc/apache2/conf.d/userdata/std/include.conf
- Add your desired Apache directives to the
/etc/apache2/conf.d/userdata/std/include.conffile. -
Rebuild the Apache configuration:
# /scripts/rebuildhttpdconf
-
Restart Apache:
# /scripts/restartsrv_apache
- Log in to the server via SSH or WHM's Terminal as the
rootuser -
Ensure the "userdata/ssl" directory exists, then create an include file.
# mkdir -pv /etc/apache2/conf.d/userdata/ssl/; touch -v /etc/apache2/conf.d/userdata/ssl/include.conf
- Add your desired Apache directives to the newly created
/etc/apache2/conf.d/userdata/ssl/include.conffile. -
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.