setup mongrel clusters and apache proxy serving via virtual host debian lenny

Assuming you have already installed Rails/Ruby

sudo gem install mongrel

sudo gem install mongrel_cluster

Then run

mongrel_rails cluster::configure -e production -p 3000 -N 2 -c /home/yourdir/yourapp -a 127.0.0.1

"production" assumes you have configured your app for production. Otherwise run "development"

You may need to open ports in iptables.

Output should be:

Writing configuration file to config/mongrel_cluster.yml.

To start mongrel cluster, cd to the rails app, then:

mongrel_rails cluster::start

restart and stop are also possible with same command

Let's also creat an init script so that mongrel will restart when server is restarted:

sudo ln -s /home/yourdir/yourapp/config/mongrel_cluster.yml /etc/mongrel_cluster/yourapp.yml

sudo cp  /usr/local/lib/ruby/gems/1.8/gems/mongrel_cluster-1.0.5/resources/mongrel_cluster /etc/init.d/ 

(debian lenny Ruby 1.8.7 Rails 2.3.2)

sudo chmod +x /etc/init.d/mongrel_cluster
 
sudo /usr/sbin/update-rc.d mongrel_cluster defaults

To start/stop/restart the cluster(s):

mongrel_cluster_ctl start
...
mongrel_cluster_ctl stop
...
mongrel_cluster_ctl restart

Original source: