Introduction
Apache configuration directives have certain contexts associated with them. The contexts that are associated with a directive determine where a directive can exist. You can read more about contexts in the Apache documentation here.
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.
This article explains how to add your custom directives to every virtualhost on the entire server. This method is based on the following documentation:
Modify Apache Virtualhosts with Includes
Procedure
To modify all virtual hosts (both port 80 and 443) use the following steps:
- Log in to the server via SSH as the root user.
- Issue the following commands:
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 modify virtualhosts for ports 80 and 443 separately, create the includes in the following places instead:
Port 80:
/etc/apache2/conf.d/userdata/std/include.conf
Port 443:
/etc/apache2/conf.d/userdata/ssl/include.conf