How to setup a full blown Mongrel Cluster powered Rails app on a CentOS server with Pound Load Balancing
=======================================================

Author: Alexandru Ungur and Robert Eaton

This little guide, outlines all the steps needed to bootstrap a full blown
Mongrel cluster powered Rails install on a brand new CentOS 4.x box. We cover all of the sofware needed as well the steps needed to actually get
it installed and configured. Following the best practices in the business,
wherever possible, the packages from standard CentOS were used, except for
situations where it came into conflict with Rails own requirements (Ruby
1.8.1 that comes with CentOS is a little too old for Rails).

Here we go:

PART I - Setting up a blank CentOS box for Rails
—————————————————————————-
==Server Set Up==

We will not go into this too deeply, but… a suggestion would be to install your unix server with a fresh install of CENTOS 4.4 without Cpanel or Plesk.

(This is what was used during the writting of this article, things may have changed since this article was written, if this article has some time against it, I suggest doing some research to see what has changed.)

CPanel has a bad habit of rewritting the apache config file which will destroy everything we are doing. Cpanel also comes with a different version of Apache than what we need. Plesk is a wonderful server admin tool, but it also conflicts with what we are doing. We suggest provisioning your server with CENTOS 4 (4.4 actually) without a control panel of any kind. Since the actual job this article was created for used a Godaddy Dedicate Unix Server. We will explain how to do this using Godaddy Servers.

==Which server to get?==

We started with a Godaddy Dedicated Unix Server. Nothing special. Just a Centos box will do! We upgraded ours with a Pentium 4 and selected the NO CONTROL PANEL OPTION. (This was actually Robert’s 3rd attempt… 1st time with plesk, second time with Cpanel, third time… NO STINKING PANEL!) Learn from my mistakes… do it right the first time and you will save 5 yourself a 5 day battle against those controlling control panels! The beautiful part about installing without a control panel with a Godaddy Centos 4 box is when you install without these panels, you get the Apache 2.0 Server with the default Centos 4.4. If you install Cpanel, we ended up with Apache 1.3! It is best to use a Centos Operating system that uses the needed services by default than to custom compile apache, the reason is because these packages are tested by many contributors in the Centos Project for bugs and security issues. When you custom compile a service like apache, you risk messing up a lot of work many people have already optimized! Unless your a guru, then I will leave that decesion up to you!
Once your server is ready… log into ssh and switch to root user.

== Exim ==

Exim is a powerfull MTA which is an excellent alternative to Sendmail. Comes by
default with CentOS and requires no setup at all to get it started on CentOS.
Just install and start it:

(make sure you remove sendmail first if it is installed)

up2date exim
service exim start
chkconfig exim on

== Subversion ==

Subversion instal consits of two parts. Installing the software and setting up
the network access to the repositories. Please refer to the documentation for the
full explanations of the format of the svnserve.conf file, but for a basic install,
disabling anonymous access and granting read/write rights to authenticated users
is usually enough.

up2date subversion
svnadmin create /var/svn
(edit /var/svn/conf/svnserve.conf, setup access)
(edit /var/svn/conf/passwd to setup users/password)
svnserve -d -r /var/svn
(add the above command to /etc/rc.d/rc.local)


== MySQL Server ==

Thanks to the excellent yum installer, the MySQL server install is a snap on any
RHEL/CentOS box:

yum groupinstall “MySQL Database”
yum install mysql-server
service mysqld start
chkconfig mysqld on

== Apache webserver ==

Once again, nothing amazing. We install the standard httpd package from CentOS,
which at the time of writting this is apache 2.0.5x

up2date httpd
(edit /etc/httpd/conf/httpd.conf to suit your needs, in our case that simply
means configuring a virtual host to proxy the requests to the balancer[1])

service httpd start
chkconfig httpd on

== Install Ruby and Rubygems software ==

These are the only packages that will be compiled from source on this guide. Due
to the fact that the versions that ship with CentOS4.4 are obsolete for Rails, we
will have to compile these from source:

wget http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.5-p2.tar.gz
tar xzf ruby*tar.gz && rm -f ruby*tar.gz
cd ruby*; ./configure && make && make install
cd ..; rm -rf ruby*

wget http://rubyforge.org/frs/download.php/20585/rubygems-0.9.3.tgz
tar xzf rubygems*tgz && rm -f rubygems*tgz
cd rubygems*; ruby setup.rb
cd ..; rm -rf rubygems*

== Install Ruby gems ==

Install the necessary Ruby gems for the application to start up and work

gem install -r rails –include-dependencies
gem install -r mongrel –include-dependencies
gem install -r mongrel_cluster –include-dependencies
gem install -r capistrano –include-dependencies

== Install Pound HTTP balancer ==

Although this is not available in CentOS either, we install this from the excellent
and worthtrusty Dag repository, in .rpm format. It’s one step better than compilling
things by hand, and the best step when packages are not available in CentOS by default

(available at: http://dag.wieers.com/rpm/packages/pound/)
wget http://dag.wieers.com/rpm/packages/pound/pound-2.3-1.el4.rf.i386.rpm
rpm -ivh pound*rpm && rm -f pound*rpm
(edit /etc/pound.cfg)
(pound # delay its start until you start the mongrel cluster first)
(add it to /etc/rc.d/rc.local)

== Fetch the Rails application ==

Typically the application is checked out from a VCS repository (subversion in this
guide) the DB access setup, and the mongrel cluster config file installed. Then
we’re ready to go

(svn co <repo>; cd app)
(install the mongrel cluster config file[3]: config/mongrel_cluster.yml)

mongrel_rails cluster::start

== Done ==

Point your browser to the domainname you configured for this Rails app and enjoy!
It should all be up & running at this point.

PART II - Adding additional Rails apps on an already configured box
—————————————————————————–

Ok, if you followed the first part of the tutorial, you should have a Rails enabled
CentOS box at this point. Now how to add aditional application… ? Quite easy :-)
All the software is already in place, which means we only need to add a couple of
configurations and we should be done. Here are the steps:

1. configure a new virtual host for the additional domain
2. configure an additional balancer for the new cluster
3. setup a new cluster for the new Rails app

So in other words, each app, gets it’s own independent cluster, which in turn requires
it’s own balancer, which in turn requires it’s own domain that will be proxied from an
Apache virtual host.

For step 1, simply use the attached config file[1] as a template, and set it up for
the new domain. What you do need to change, besides the domainname of course, is the
port you will redirect to. That port is the same port pound will listen on. So, suppose
the first application uses port 82 like in the sample config file, then for an additional
app you would use the next port, say 83. Then what you need to do is this:

1. create a new virtual host using port 83 to proxy the requests to, or whatever port you wan, we are using port 83 in this example.

2. Then create an additional pound config file, you could name it /etc/pound2.cfg

Use for this one the pound config template[2] but modify the port it listens to
from 82 to 83. Now the new apache virtual host will correctly proxy the requests
to the new pound balancer, which is configured properly to listen on a new port.
There’s one more step now needed for pound:
Change the ports for the cluster. In the template we use ports 8000 to 8003
for the four mongrels that are part of the first cluster, so we need now another
four ports. Simply pick the next four, 8004 to 8007 and replace them accordingly
in the new pound config file. That’s it for pound. Now it knows to listen on the
new port and to forward the requests to the new ports. Let’s setup a new mongrel
cluster now.

3. Use the template[3] and copy it in the config folder of the new Rails app we’re
setting up right now. Edit the first line to start from 8004 instead of 8000
and that’s it for Mongrel.

Now, with all the files in place, we’re ready to start it all.
1. cd to the root of the new Rails app and issue:

mongrel_rails cluster::start

2. run this to start the balancer:

pound -f /etc/pound2.cfg

3. and this to restart apache

service httpd restart

Enjoy it! :-)
Your new Rails app, should be up and running now :-)

Sample config files used in this guide
=======================================

[1] Sample apache setup for proxying requests to a balancer

<VirtualHost *:80>
ServerName ruby.cookbookwiki.com
ProxyPass / http://127.0.0.1:82/
ProxyPassReverse / http://127.0.0.1:82
ProxyPreserveHost on
</VirtualHost>

[2] Simple pound configuration for a cluster with 4 mongrels

ListenHTTP
Address 0.0.0.0
Port 82
Service
BackEnd
Address 127.0.0.1
Port 8000
End
BackEnd
Address 127.0.0.1
Port 8001
End
BackEnd
Address 127.0.0.1
Port 8002
End
BackEnd
Address 127.0.0.1
Port 8003
End
End
End

[3] Sample 4 mongrel clusters config file

port: 8000
pid_file: /tmp/test-mongrel.pid
servers: 4
address: 127.0.0.1
environment: development

viagra now
best viagra cheap
best viagra alternative delivery
best viagra alternatives in canada
beta blockers and viagra
bigger penis with viagra
bio viagra
bio viagra herbal fast
brand name viagra for purchase buy
brand viagra without prescription
buy brand name viagra
buy cheap viagra canada
buy cheap viagra online
buy cheap viagra uk fast
buy discount viagra buy
buy female viagra
buy female viagra online
buy generic viagra canada rx
buy generic viagra india rx cheap
buy in spain viagra cheap
buy pfizer viagra
buy real viagra delivery
buy real viagra online without prescription
buy real viagra without prescription
buy viagra canada
buy viagra cheap pills
buy viagra china discounts
buy viagra fast
buy viagra from india delivery
buy viagra gel
buy viagra in canada no prescription
buy viagra next day
buy viagra no prescription buy
buy viagra online pills
buy viagra online without prescription delivery
buy viagra out a prescription
buy viagra without a prescription
buy viagra without prescription buy
buying generic viagra canada rx cheap
buying generic viagra in the united states
buying generic viagra mexico rx
buying generic viagra usa pills
buying real viagra without prescription pharmacy
buying viagra 50 mg delivery
buying viagra now discounts
buying viagra online buy
buying viagra online cheap us germany
buying viagra soft tablets 50 mg canada
buying viagra with no prescription online
can you buy viagra in canada discounts
can you buy viagra without a prescription
canada pharmacy viagra pfizer pills
canada viagra
canada viagra sale now
canadian pharmacies viagra
canadian pharmacy viagra
canadian pharmacy viagra pfizer online
canadian viagra sales
canadian viagra best deals
canadian viagra pfizer
cheap canadian viagra buy
cheap viagra for sale discounts
cheap viagra from canada canada
cheap viagra from india
cheap viagra in canada
cheapest prices for viagra
cheapest viagra
cheapest viagra in canada usa
cheapest viagra online
cheapest viagra prescription
cheapest viagra without a prescription
cialis levitra viagra
cost of viagra
do women require viagra
erection viagra gel
fast viagra delivery sales
female viagra now
free viagra pharmacy
functional drink similar to viagra discounts
generic viagra delivery
generic viagra 100 mg
generic viagra 50 mg
generic viagra canada
generic viagra for sale buy
generic viagra india usa
generic viagra mexican fast
generic viagra on line now
generic viagra overnight sales
generic viagra overnight delivery
generic viagra without prescription
herbal alternative to viagra
herbal viagra
how does viagra work cheap
how much is viagra from canada pills
how much viagra delivery
how much viagra costs
how to buy viagra
how to buy viagra tablets
how to get viagra
how to get viagra canada fast
how to get viagra in uk
how to get viagra no prescription
india viagra
indian genric viagra
indian viagra
low coast viagra
low cost viagra
mexican generic viagra
minerals in viagra
natural viagra buy
no prescription canadian viagra sales
no prescription viagra online
no prescription viagra canada canada
no rx viagra
non prescription free viagra
non prescription viagra online
non prescription viagra fast delivery pills
online cheap viagra
online order viagra overnight delivery
online viagra gel
online viagra next day delivery
order usa viagra online discounts
order viagra
ordering viagra from canada
ordering viagra overnight delivery
overnight generic viagra
pfizer viagra
pfizer viagra 50 mg pharmacy
pfizer viagra cheap
pfizer viagra online
prices of viagra pills in india delivery
purchase viagra express delivery
purchase viagra fast delivery sales
purchase viagra with no prescription sales
quick delivery of generic viagra pharmacy
real viagra
real viagra online pills
soft viagra
uk deals cheap viagra
viagra 100 mg
viagra 100 mg canadian usa
viagra 50 mg germany
viagra alternative pills
viagra and beta blockers buy
viagra and tegretol
viagra and weight lifting
viagra available in canada
viagra bigger erection
viagra blue pill online
viagra brand canadian
viagra brand cheap no prescription
viagra buy
viagra canada delivery
viagra canada online pharmacy canada
viagra canadian
viagra canadian pharmacy
viagra canadian pharmacy dosage germany
viagra cream gel fast
viagra discounted
viagra dosage
viagra dose
viagra effects on the penis online
viagra en gel delivery
viagra express delivery canada
viagra fast
viagra fast delivery discounts
viagra flex buy germany
viagra for sale
viagra for sale in canada buy
viagra for weightlifting
viagra for women delivery
viagra from canada fast
viagra from canda pills
viagra from india
viagra from mexico
viagra gel
viagra generic
viagra generic canada pills
viagra generic in mexico
viagra generics in mexico now
viagra germany pills
viagra how fast does it work fast
viagra how to use
viagra in china discounts
viagra in gel
viagra in spain
viagra india buy
viagra label
viagra manufactured united states
viagra next day delivery usa
viagra no prescription
viagra no rx
viagra online cheap
viagra online ordering
viagra original pfizer order
viagra overnight
viagra overnight delivery fast
viagra penis usa
viagra pfizer delivery
viagra pfizer 50 mg
viagra pills pills
viagra pills 100 mg
viagra porn
viagra prescription canada usa
viagra prescription label online
viagra price germany
viagra prices
viagra professional online
viagra professional 100 mg
viagra sale
viagra sales delivery
viagra samples
viagra sauna germany
viagra side effects fast
viagra soft pills
viagra soft tablets
viagra soft tabs 100 mg
viagra spain cheap
viagra specials sales
viagra tablet
viagra tablet weight delivery
viagra tablets
viagra tablets sale
viagra to canada
viagra usa
viagra usa online
viagra with dofetilide
viagra without a prescription pills
viagra without prescription
viagra without rx
what better viagra or cialis
where can buy viagra
where can i buy real viagra
where can i buy viagra
where can i get viagra pharmacy
where can purchase viagra
where to buy real viagra canada
where to buy viagra fast pharmacy
where to find real viagra usa
where to get viagra
cialis
50 mg cialis
50 mg cialis dose delivery
best buys generic cialis pills
best cialis price
best price cialis
best price for generic cialis
best way to take cialis
best way to use cialis
billig cialis
bipolar and cialis
brand cialis germany
brand cialis for sale
brand name cialis
buy cheap cialis without a prescription
buy cialis cheap
buy cialis canada delivery
buy cialis cheap delivery
buy cialis cheap prices fast delivery delivery
buy cialis cheap us sales
buy cialis doctor online cheap
buy cialis fast delivery pills
buy cialis fedex shipping online
buy cialis generic pharmacy online
buy cialis next day
buy cialis next day delivery buy
buy cialis online
buy cialis online canada
buy cialis online from canada buy
buy cialis online pharmacy
buy cialis online uk
buy cialis online without prescription pharmacy
buy cialis overnight
buy cialis phentermine
buy cialis without prescription
buy cialisnext day shipping sales
buy generic cialis fast
buy generic cialis canada rx discounts
buy generic cialis expressdelivery germany
buy generic cialis india rx usa
buy generic cialis mexico rx online
buy generic cialis usa
buy real cialis online
buy real cialis online without prescription
buying cialis
buying cialis fast delivery usa
buying cialis next day delivery canada
buying cialis online
buying cialis prescription
buying cialis soft tabs 100 mg
buying generic cialis canada rx now
buying generic cialis in the united states
buying generic cialis mexico rx
canada brand name cialis discounts
canada pharmacy cialis pfizer
canadian generic cialis drugs buy
canadian pharmacy cialis
canadian pharmacy cialis pfizer
canadian pharmacy online generic cialis pharmacy
cheap cialis online
cheap cialis over internet
cheap cialis professional
cheap generic cialis canadian
cheap natural alternatives of cialis usa
cheapest cialis
cheapest cialis buy
cheapest cialis fast delivery delivery
cheapest cialis on the internet
cheapest cialis overnight delivery online
cheapest price cialis
cheapest prices on cialis
cialis 100 mg
cialis 20 mg delivery
cialis 30 mg now
cialis 5 mg buy
cialis 50 mg
cialis alternative buy
cialis alternatives no prescription discounts
cialis and cialis professional
cialis and ketoconazole
cialis angioplasty
cialis atrial fibrillation
cialis au
cialis bodybuilding
cialis brand discounts
cialis brand name buy
cialis buy cheap
cialis buy overseas usa
cialis by mail
cialis canada
cialis canada fda
cialis canada online pharmacy
cialis canada pharmacy fast
cialis canadian
cialis canadian cost
cialis canadian pharmacy
cialis cheap
cialis cheap us
cialis delivered overnight
cialis discount
cialis dosage
cialis doses
cialis express delivery delivery
cialis fast delivery
cialis fast delivery usa
cialis for cheap
cialis for sale
cialis for woman usa
cialis for women pills
cialis from mexico
cialis from overseas
cialis gel
cialis generic
cialis india sales
cialis kanada
cialis levitra viagra
cialis low price
cialis medication sales
cialis my wife pills
cialis natural alternatives discounts
cialis neutropenia leukopenia pills
cialis next day delivery pills
cialis no prescription
cialis no prescription pharmacy discounts
cialis no prescription requires
cialis online
cialis online 2 3 days delivery sales
cialis online canada
cialis online no prescription
cialis online pharmacy
cialis online without prescription fast delivery
cialis order pills
cialis ordering overnight
cialis ordering overnight delivery pharmacy
cialis overnight
cialis overnight delivery
cialis overnight mail delivery
cialis overnight without a prescription
cialis philippines
cialis pills
cialis prescription buy
cialis price sales
cialis price 100mg
cialis prices
cialis profesional
cialis professional online
cialis professional 100 mg
cialis professional no prescription usa
cialis professional singapore
cialis purchase
cialis samples
cialis sleeplessness
cialis soft
cialis soft canada
cialis soft tablets
cialis soft tablets 100 mg
cialis soft tablets cheapest price pills
cialis soft tabs 100 mg buy
cialis specials
cialis suppliers
cialis trazodone online
cialis vitamin d germany
cialis without prescription
compare cialis to herbal
discount canadian cialis germany
discount cialis
discount cialis fast delivery sales
erection cialis gel
find cialis online
free cialis
generic cialis
generic cialis 100 mg
generic cialis buy usa
generic cialis buy now canada buy
generic cialis canada buy
generic cialis cheap
generic cialis next day
generic cialis next day delivery pharmacy
generic cialis overnight
generic cialis soft tabs
generic cialis united states
generic cialis without perscription buy
generic cialis without prescription
get cialis online
herbal alternative to cialis
how much cialis costs
how much does cialis cost
how quick does a cialis work
how to buy cialis in canada
how to get cialis pills
how to get cialis in canada delivery
how to get cialis no prescription
hydrochlorothiazide cialis canada
indian cialis generic pharmacy
inquiry cialis
low cost cialis sales
low price cialis
map of france with cialis pills
my canadian pharmacy cialis usa
name brand cialis
natural cialis
no prescription cialis professional
online cialis now
online cialis sales
online cialis with no prescription
online generic cialis 100 mg
order cialis next day delivery
ordering cialis gel sales
ordering cialis natural alternatives
ordering cialis next day delivery cheap
ordering cialis overnight delivery buy
ordering cialis with no prescription cheap
over night delivery of cialis online
overnight cialis brand
overnight delivery cialis usa
pfizer cialis sales
pfizer cialis online sales
pharmacy cialis
pharmacy online genric cialis pills
prescription cialis pharmacy
prescription cialis online brand name
professional cialis
professional cialis online
purchase cialis
purchase cialis cheap
purchase cialis cheapest
purchase cialis express delivery germany
purchase cialis overnight delivery
purchase cialis with discount
purchasing cialis now
purchasing cialis with next day delivery
real cialis
real cialis online
reputable online cialis brand name
soft cialis
the name generic cialis
the truth about cialis fast
truth about cialis canada
unpleasant stuff of cialis
viagra 50 mg compare cialis
what better viagra or cialis
what is cialis professional germany
where can i get cialis canada
where can i purchase cialis pharmacy
where can i purchase cialis overnite
where to buy cialis online
where to get cialis cheap
woman testimonial of cialis canada

Sphere: Related Content