Skip to content

Instantly share code, notes, and snippets.

@beef
Created May 19, 2009 14:13
Show Gist options
  • Save beef/114114 to your computer and use it in GitHub Desktop.
Save beef/114114 to your computer and use it in GitHub Desktop.
Staging and Live Apache Set Up
<VirtualHost *>
<Directory /var/www/default/current/public>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from All
</Directory>
DocumentRoot /var/www/default/current/public
ServerName www.myapp.com
ErrorLog /var/www/myapp.com/log/default_error.log
CustomLog /var/www/myapp.com/log/default_access.log combined
# Gzip/Deflate
# http://fluxura.com/2006/5/19/apache-for-static-and-mongrel-for-rails-with-mod_deflate-and-capistrano-support
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript text/css application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Far future expires date
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT"
</FilesMatch>
# No Etags
FileETag None
RewriteEngine On
# Check for maintenance file and redirect all requests
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /system/maintenance.html [L]
# Static cache
RewriteCond %{REQUEST_METHOD} !^POST$
RewriteCond /var/www/default/current/tmp/cache/static$1/index.html -f
RewriteRule ^(.*)$ /var/www/default/current/tmp/cache/static$1/index.html [L]
</VirtualHost>
<VirtualHost *>
<Directory /var/www/staging/current/public>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from All
</Directory>
DocumentRoot /var/www/staging/current/public
ServerName dev.myapp.com
RailsEnv staging
ErrorLog /var/log/apache2/staging_error.log
CustomLog /var/log/apache2/staging_access.log combined
# Gzip/Deflate
# http://fluxura.com/2006/5/19/apache-for-static-and-mongrel-for-rails-with-mod_deflate-and-capistrano-support
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript text/css application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# No Etags
FileETag None
RewriteEngine On
# Check for maintenance file and redirect all requests
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /system/maintenance.html [L]
# Static cache
RewriteCond %{REQUEST_METHOD} !^POST$
RewriteCond /var/www/staging/current/tmp/cache/static$1/index.html -f
RewriteRule ^(.*)$ /var/www/staging/current/tmp/cache/static$1/index.html [L]
#<Location />
# AuthName "Staging area is password protected"
# AuthType Basic
# AuthUserFile /var/www/staging/conf/passwords
# Require valid-user
#</Location>
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment