Skip to content

Instantly share code, notes, and snippets.

@xavierRiley
Created January 5, 2012 16:39
Show Gist options
  • Save xavierRiley/1566036 to your computer and use it in GitHub Desktop.
Save xavierRiley/1566036 to your computer and use it in GitHub Desktop.
Sample vhost for php sites
<VirtualHost *:80>
ServerName SITE_URL
ServerAlias SITE_IP *.SITE_URL
DocumentRoot /var/www/SITE_URL/PUBLIC_FOLDER
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "/var/www/SITE_URL/PUBLIC_FOLDER">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
# Deflate
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
ErrorLog /var/log/apache2/SITE_URL.error.log
CustomLog /var/log/apache2/SITE_URL.access.log combined
<IfModule mod_expires.c>
# any Expires Directives go here
ExpiresActive On
ExpiresDefault A86400
ExpiresByType image/x-icon A2592000
ExpiresByType application/x-javascript A2592000
ExpiresByType text/css A2592000
ExpiresByType image/gif A604800
ExpiresByType image/png A604800
ExpiresByType image/jpeg A604800
ExpiresByType text/plain A604800
ExpiresByType application/x-shockwave-flash A604800
ExpiresByType video/x-flv A604800
ExpiresByType application/pdf A604800
ExpiresByType text/html A900
</IfModule>
<IfModule mod_headers.c>
# any Header directives go here
# 1 YEAR
<FilesMatch "\.(ico|pdf|flv)$">
Header set Cache-Control "max-age=29030400, public"
</FilesMatch>
# 1 WEEK
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
# 2 DAYS
<FilesMatch "\.(xml|txt|css|js)$">
Header set Cache-Control "max-age=172800, proxy-revalidate"
</FilesMatch>
# 1 MIN
<FilesMatch "\.(html|htm|php)$">
Header set Cache-Control "max-age=60, private, proxy-revalidate"
</FilesMatch>
</IfModule>
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment