June 2025
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
30  

Categories

June 2025
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
30  

SHORTENING APACHE CONFIGS USING MOD_MACRO

It is possible to use macros in the Apache config files to shorten them and make them easier to read and manage. To use this you have to install mod_macro if it’s not already installed in your distribution.

Sample mod_macro usage



ServerName $domain
ServerAlias www.$domain
DocumentRoot /vaw/www/$customer/htdocs/$domain/
ScriptAlias /cgi-bin/ /var/www/$customer/cgi-bin/
ErrorLog /var/log/apache/$customer/logs/$domain-error.log
CustomLog /var/log/apache/$customer/logs/$domain-access.log combined

Options ExecCGI,noIndexes


Use VHost customer_A example.com
Use VHost customer_B example.net
Use VHost customer_C example.org
Another example


AuthName “Restricted area”
AuthType Basic
AuthUserFile /var/www/.htpasswd
require valid-user


Options Indexes


Use PasswordProtect
Options -Indexes


Use PasswordProtect
Options +FollowSymLinks

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>