Apache 2.4 added a seemingly little known feature, setting and using variables in config files. It took me some time to find any information about this but it is in the documentation. It’s simple enough to use, at the beginning of your file you define the variable with Define, then you can access it with ${variable}. An example:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
Define docroot "/var/www/vhosts/myhost/public" <VirtualHost *:80> ServerName myhost.local DocumentRoot ${docroot}/ <Directory ${docroot}> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> </VirtualHost> |