Monday, January 15, 2007

FreeBSD+Mongrel Cluster+Pound, Kickass Rails Environment

How easy to setup a Rails web server?? you may try this combination, FMcP(FreeBSD+Mongrel_Cluster+Pound). Note that pound is not a web server, it's just a reverse proxy and balancer that interact with mongrel clusters.

step 1: install mongrel & mongrel_cluster

$sudo gem install mongrel
$sudo gem install mongrel_cluster

step 2: install Pound reverse proxy

$pkg_add -r pound

[/usr/local/etc/pound.cfg]
ListenHTTP 0.0.0.0,80

UrlGroup ".*"
BackEnd 127.0.0.1,8000,1
BackEnd 127.0.0.1,8001,1
BackEnd 127.0.0.1,8002,3
EndGroup

UrlGroup ".*.(js|css|jpg|jpeg|bmp|gif|swf)"
BackEnd 127.0.0.1,8003,1
BackEnd 127.0.0.1,8004,1
EndGroup

[end]

$echo "pound_enable=\"YES\"" >> /etc/rc.conf

step 3: configure mongrel cluster

$cd railsapp
$mongrel_rails cluster::configure -a 127.0.0.1 -p 8000 -N 5 -e production
$mongrel_rails cluster::start
$tail log/mongrel.log <-- to see whether the service start successfully

step 4: start pound

$pound -f /usr/local/etc/pound.cfg

That's it!! Run ur rails app at http://127.0.0.1

more about Pound

No comments: