{"id":6997,"date":"2017-09-12T15:04:17","date_gmt":"2017-09-12T07:04:17","guid":{"rendered":"http:\/\/rmohan.com\/?p=6997"},"modified":"2017-09-12T15:04:17","modified_gmt":"2017-09-12T07:04:17","slug":"shortening-apache-configs-using-mod_macro","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=6997","title":{"rendered":"SHORTENING APACHE CONFIGS USING MOD_MACRO"},"content":{"rendered":"<p>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\u2019s not already installed in your distribution.<\/p>\n<p>Sample mod_macro usage<\/p>\n<p><Macro VHost $customer $domain><br \/>\n<VirtualHost $domain:80><br \/>\n  ServerName $domain<br \/>\n  ServerAlias www.$domain<br \/>\n  DocumentRoot \/vaw\/www\/$customer\/htdocs\/$domain\/<br \/>\n  ScriptAlias \/cgi-bin\/ \/var\/www\/$customer\/cgi-bin\/<br \/>\n  ErrorLog \/var\/log\/apache\/$customer\/logs\/$domain-error.log<br \/>\n  CustomLog \/var\/log\/apache\/$customer\/logs\/$domain-access.log combined<br \/>\n  <Directory \/var\/www\/$customer\/cgi-bin\/><br \/>\n    Options ExecCGI,noIndexes<br \/>\n  <\/Directory><br \/>\n<\/VirtualHost><br \/>\n<\/Macro><\/p>\n<p>Use VHost customer_A example.com<br \/>\nUse VHost customer_B example.net<br \/>\nUse VHost customer_C example.org<br \/>\nAnother example<\/p>\n<p><Macro PasswordProtect><br \/>\nAuthName &#8220;Restricted area&#8221;<br \/>\nAuthType Basic<br \/>\nAuthUserFile \/var\/www\/.htpasswd<br \/>\nrequire valid-user<br \/>\n<\/Macro><\/p>\n<p><Directory \/var\/www\/domain\/htdocs><br \/>\nOptions Indexes<br \/>\n<\/Directory><br \/>\n<Directory \/var\/www\/domain\/htdocs\/internal><br \/>\nUse PasswordProtect<br \/>\nOptions -Indexes<br \/>\n<\/Directory><br \/>\n<Directory \/var\/www\/domain\/htdocs\/downloads><br \/>\nUse PasswordProtect<br \/>\nOptions +FollowSymLinks<br \/>\n<\/Directory><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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\u2019s not already installed in your distribution.<\/p>\n<p>Sample mod_macro usage<\/p>\n<p> 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 [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6997"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6997"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6997\/revisions"}],"predecessor-version":[{"id":6998,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6997\/revisions\/6998"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6997"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6997"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6997"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}