February 2011
« Jan   Mar »

Rails deployment : Phusion Passenger made easy

Earlier times I had faced many difficulties to host the Rails applications especially on shared hosting where we have limited access. Apache can serve the rails pages in CGI/FastCGI mode normal and proxing rails to mongrel web server. I’d also work with Bluehost RoR environment which will be headache in hosting few years before.

I’d pretty good experience with mongrel and done the mongrel load balancing using apache proxy module. Here is the time passenger made easy everything and simple.

Here we go,

Install Passenger gems and Apache Module.
a. #gem install passenger
b. #passenger-install-apache2-module
c . Next you need to configure httpd.conf and set virtual host for rails hosting. Uncomment “NameVirtualHost *:80” on httpd.conf
d. [root@rc-040 public_html]# vi /etc/httpd/conf.d/mydomain.conf

<VirtualHost *:80>


DocumentRoot /home/myrailsapps/public_html/public/

<Directory /home/myrailsapp/public_html/public/>

AllowOverride allOptions -MultiViews



I set the document root to exactly on the “public” folder in the rails project. Restart Apache
# service httpd restart

Now everything should work normally.

If you see an error messages as below,

This because of passenger is using rails”production” enviroment by default. So you have to correct the database settings under “production” line inside “/config/database.yml” file. A sample entry should be like this,

adapter: mysql
encoding: utf8
reconnect: false
host :
database: mydb
pool: 5
username: dbuser
password: userpassword
socket: /var/lib/mysql/mysql.sock

Then restart httpd
[root@rc-040 public_html]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]

You made it working Ahhhh .!! 🙂

How to test the rails project is error free for the hosting.
I used to test every rails application running on webric server before setting up hosting environment in passenger.

1. Webric (Rails standalone web server)
Go to rails project directory and execute
[root@rc-040 public_html]# ruby script/server -p3000
=> Booting Mongrel
=> Rails 2.3.5 application starting on
=> Call with -d to detach
=> Ctrl-C to shutdown server
Browse the site at http://localhost:3000

2. Using mongrel
#gem install mongrel

[root@rc-040 public_html]# <strong>mongrel_rails start -p 3000</strong>
** Starting Mongrel listening at
** Starting Rails with development environment...
** Rails loaded.
** Loading any Rails specific GemPlugins
** Signals ready.  TERM =&gt; stop.  USR2 =&gt; restart.  INT =&gt; stop (no restart).
** Rails signals registered.  HUP =&gt; reload (without restart).  It might not work well.
** Mongrel 1.1.5 available at
** Use CTRL-C to stop

1 comment to Rails deployment : Phusion Passenger made easy

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>