Last active
January 3, 2016 10:59
-
-
Save ronanguilloux/8452588 to your computer and use it in GitHub Desktop.
Macro-based apache2 vhost
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install: | |
# $ sudo apt-get install libapache2-mod-macro | |
# $ sudo a2enmod macro | |
# Usage: | |
# $ echo "Use VHost /opt/web/sites myNewSite 80" > /etc/apache2/sites-available/myNewVhost.conf | |
# copy & paste this below inside a new /etc/apache2/conf.d/vhost.macro file: | |
<Macro VHost $path $host $port> | |
<VirtualHost *:$port> | |
Servername $host | |
DocumentRoot $path/$host/web | |
<Directory $path/$host/web> | |
Options FollowSymLinks | |
AllowOverride All | |
Order allow,deny | |
Allow from all | |
</Directory> | |
SetEnvIf Request_URI "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf|txt|cur)$" dontlog | |
SetEnvIf Request_URI "^_" dontlog | |
SetEnvIf Request_URI "^/_" dontlog | |
LogFormat "%V %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \"%{cookie}i\" test" combined_cookie_vhost | |
CustomLog ${APACHE_LOG_DIR}/access.$host.com.log combined_cookie_vhost env=!dontlog | |
ErrorLog ${APACHE_LOG_DIR}/error.$host.com.log | |
# Possible values include: debug, info, notice, warn, error, crit, alert, emerg. | |
LogLevel warn | |
#LogLevel debug | |
#php_flag apc.cache_by_default Off | |
<IfModule mod_expires.c> | |
ExpiresActive on | |
ExpiresByType text/css "access plus 0 seconds" | |
ExpiresByType application/javascript "access plus 0 seconds" | |
</IfModule> | |
<IfModule mod_headers.c> | |
Header set X-UA-Compatible: "IE=edge,chrome=1" | |
</IfModule> | |
</VirtualHost> | |
</Macro> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment