Satya's blog - Rails and Mongrel

May 24 2007 21:26 Rails and Mongrel

Okay, you have a Ruby on Rails project, and Mongrel. Suppose your project is 'spiffy' and can be found at http://yourspiffyserver.com/spiffy

In config/routes.rb, add:
ActionController::AbstractRequest.relative_url_root = "/spiffy"

Somewhere in your default routes, in the same routes.rb file, add the route to your default controller and method, the things you want to hit when someone goes to http://yourspiffyserver.com/spiffy
map.connect '', :controller => 'home', :action => 'index'

Symlink your public directory to your project name:
cd public && ln -s . spiffy

Be sure to give your web server write access to log/ and tmp/ with a chown -R.

Add something like the following in your Apache config (remember, this is for Mongrel):
ProxyPass /spiffy http://127.0.0.1:8200/spiffy
ProxyPassReverse /spiffy http://127.0.0.1:8200/spiffy
(8200 = port that mongrel is listening on for this site.)

Add to /etc/mongrel/sites-available/ a file called spiffy or spiffy.conf containing:
# RAILS_ROOT of your application
dir=/home/rails_apps/spiffy
# port the first mongrel instance should listen to, additional instances will us e ports above this
port=8200
# number of mongrel instances -- more if your app is hit heavily. They use ports starting at 'port' and up. So, 8200, 8201, etc.
servers=1

As usual, these instructions may or may not work for you.

Tag: howto geeky rails