Rails on mongrel

software development


Yes, I have a rails site working on mongrel with Dreamhost! It definitely feels faster than with fastcgi, and the memory usage appears to be better as well (anecdotal, not benchmarked).

Here’s how:

  1. Get a Dreamhost PS.

  2. Set up a gem environment in your $HOME so you can install your own gems.

  3. Install the required gems: mongrel_cluster, plus dependencies…

  4. Use the DH panel to add a proxy server on the domain, with a directory name such as “/mongrel_proxy/”, port 8000

  5. Create a mongrel configuration file in your project with the following. If you use capistrano, configure with the “current” and “shared” directories as shown below, otherwise just use yourapp.com without subdirectories:

sudo mongrel_rails cluster::configure
-e production
-p 8000
-N 1
-c /home/user/yourapp.com/current
-P /home/user/yourapp.com/shared/pids/mongrel.pid \
-C /home/user/yourapp.com/current/config/mongrel_cluster.yml

  1. Add the following to your public/.htaccess file.

Send all dynamic file requests to the cluster proxy

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /mongrel_proxy/$1 [QSA,L]

  1. Start the server with:

a. using Capistrano: cap deploy
b. Manually: mongrel_rails cluster::start -C $HOME/yourapp.com/current/config/mongrel_cluster.yml

(You may want to add the above start script as a cron job “on reboot”)

This all seems to work great, but I’m finding the mongrel_cluster process actually disappears after a while (I’m guessing about an hour?). Is it being killed by DH? I thought I should be able to run my own daemon processes on the Dreamhost PS plan, especially since that’s what the proxy server feature is for… Any clue what might be going on?


Can someone provide instructions on setting up mongrel_cluster to work out of my home directory?

  1. install rubygems locally

Tried teh instructions on rubygems.org, but it didn’t make any sense after installing and running. It just uses the old stuff, or fails on the local version.


These days I think it makes more sense to use DH’s new mod_rails/passenger hosting instead of mongrel…