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:
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/
- Add your desired Apache directives to the include.conf file.
- Rebuild the Apache configuration:
- Restart Apache:
To modify virtualhosts for ports 80 and 443 separately, create the includes in the following places instead: