Skip to content

Instantly share code, notes, and snippets.

@jeffjohnson9046
Created January 9, 2014 20:50
Show Gist options
  • Save jeffjohnson9046/8341749 to your computer and use it in GitHub Desktop.
Save jeffjohnson9046/8341749 to your computer and use it in GitHub Desktop.
An apache virtual host file for a Ruby on Rails app. Typically, this file will live in /etc/httpd/conf.d
<VirtualHost *:80>
ServerName # put my server name here
## Vhost docroot
DocumentRoot /path/to/app/root # if your app's root directory is /opt/myapp, this should be set to /opt
## Alias declarations for resources outside the DocumentRoot
Alias /myapp /path/to/app/public/directory # if your app's root directory is /opt/myapp this should be set to /opt/myapp/public
Alias /assets /path/to/app/public/assets/directory # if your app's root directory is /opt/myapp this should be set to /opt/myapp/public/assets
## Directories, there should at least be a declaration for /opt/myapp/public
<Location /myapp>
RackBaseURI /myapp
PassengerAppRoot /opt/myapp
RailsEnv production
</Location>
<LocationMatch "^/assets/.*$">
# Some browsers still send conditional-GET requests if there's a
# Last-Modified header or an ETag header even if they haven't
# reached the expiry date sent in the Expires header.
# Header unset Last-Modified
Header unset ETag
FileETag None
# RFC says only cache for 1 year
ExpiresActive On
ExpiresDefault "access plus 1 year"
</LocationMatch>
<Directory /opt/myapp/public>
Options -MultiViews
AllowOverride all
Order allow,deny
Allow from all
PassengerEnabled on
</Directory>
## Load additional static includes
## Logging
ErrorLog /var/log/httpd/myapp_error.log
ServerSignature Off
CustomLog /var/log/httpd/myapp_access.log combined
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment