Home > Installation > Setting up a webserver for Rails
login

© Metadot Corporation

Setting up Apache 2 for Rails  

Lots of information about it can be found here: Setting up a webserver for Rails

Here is our quick recipe:

# cat /etc/apache2/sites-enabled/metadot.conf

 <VirtualHost 201.11.101.131:80>
  ServerName yourco.edu
  ServerAlias www.yourco.edu
  DocumentRoot /var/www/sites/metadot/metadot-rails/public
  <Directory /var/www/sites/metadot/metadot-rails/public>
    Options -Indexes FollowSymLinks ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

 

 

# cd /var/www/sites/metadot/metadot-rails/public

# cat .htaccess

# Look in /etc/apache2/mods-enabled/fcgid.conf to see how fcgi is
# configured
###
RewriteEngine On
<IfModule mod_fcgid.c>
  AddHandler fcgid-script .fcgi
</IfModule>

Options +Indexes +MultiViews +FollowSymLinks +ExecCGI
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]

###
### For out of service situation, enable the following two lines.
###
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteRule ^(.*)$ out_of_service.html [QSA,L]

# Redirect all requests not available on the filesystem to Rails
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !/__metadot__/public(.*)
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

ErrorDocument 500 "<h2>Application error</h2><p>Rails application failed to start properly.</p>"