Apache - Rails Checklist
Deployment is an important element for any Rails application. While you iron out all the logical kinks in your application running Webrick, suprises may await you when you deploy. Have you encountered the “Application Error” screen when an application is deployed?
I decided to use my local Ubuntu box as a trial run for the complete deployment setup. That means using the exact same configuration my hosting provider uses. We are using Apache-fcgi for now and hoping to migrate soon to Apache-mongrel.
Here is a checklist of items to check as you set your environment. YMMV — and hoping that you do not run into these. The documentation on this is very sparse and for every question there will be different answers ranging from a band-aid to OS reinstall. So read through the post before you set off on the venture and make sure you have all the links handy.
This assumes you have installed apache, tested the basic page and can see the home public_html for a user
* Enable rewrite
sudo a2enmod rewrite
* fcgi module for apache
sudo apt-get install libfcgi-ruby1.8 libapache2-mod-fastcgi sudo a2enmod fastcgi
* fcgi gem for rails
sudo gem install fcgi
* Use either a virtual host or a alias to access the rails app
- Make sure to use RewriteBase in your .htaccess only if using alias
- add the host with sudo a2ensite
- if you use virtual site, add 127.0.0.1 localhost,
* Fix permissions for rails directories so apache can use them
Ref: http://bryan.e4industries.com/?p=6
sudo chgrp -R www-data railsapp chmod 0775 db chmod 0777 log chmod 0775 public chmod 0666 log/*.log
* Edit railsapp/public/.htaccess to enable fastcgi
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
* Check dispatch.fcgi and ensure the #!path in the first line points to the valid ruby source
* It is /usr/local/bin/ruby by default, Ubuntu has ruby in /usr/bin/ruby
References:
February 10th, 2007 at 1:27 pm
Very nice writeup. I was struggling with the exact same problem This helped me a lot.
April 12th, 2007 at 2:53 pm
Thanks. This is exactly what I was looking for. Worked exactly as you have written up.
June 12th, 2007 at 7:06 pm
I Googled for something completely different, but found your page…and have to say thanks. nice read….