Phat Site Blog

Tag: phusion passenger

Get Your New Server Setup with Ruby on Rails and Phusion Passenger

by admin on Feb.15, 2009, under Server Maintenance

Phusion Passenger will make your web applications run without any need to do maintenance.  Let it moderate the resources by itself!

Phusion Passenger (mod_rails/mod_rack) is an apache module that makes deployment of Ruby/Rails applications as simple as PHP applications. It does not require use of any ruby specific tools to deploy application. All you have to do is copy your source files in appropriate directories on server and your code changes will be deployed. Main advantage of passenger is it allows to deploy rails application reliably on shared hosting environment. Passenger is not available for windows.

Lets see how to install Passenger on Cent OS. Cent OS 5.1 comes with Apache 2.2.3 installed. First of all make sure Ruby, Gems, Rails and ruby development headers is installed on the system, Issue following commands as root:

yum install ruby
yum install irb
yum install rdoc
yum install ruby-devel

Installing rubygems manually because distro dependencies:
wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
tar -zxvf rubygems-1.3.1.tgz
ruby setup.rb

If you get:
RubyGems installed the following executables:
/usr/bin/gem

RubyGems is install and let’s move on.

Now install rails gems, it might take a while:

gem install rails -y
yum install httpd-devel – this might be already installed

Now, we are ready to install passenger.  It’s actually pretty easy to setup:
gem install passenger

After installing passenger and its dependencies make sure that Apache is stopped, launch passenger installer for Apache module from command line.

passenger-install-apache2-module

This will setup Apache2, teach you to configure apache and deploy your Ruby App.  You will be given instructions to add a few lines to the apache configuration file, let’s do that now.

vim /etc/httpd/conf/httpd.conf

Look for this:
#
# The following modules are not loaded by default:
#
#LoadModule cern_meta_module modules/mod_cern_meta.so
#LoadModule asis_module modules/mod_asis.so

And add these three lines right below it:

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.0.6/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.0.6
PassengerRuby /usr/bin/ruby

After the module is installed, go ahead and create a user app.  I’ll show you how to make one if you created a new user. Run:
su newuser
cd /home/newuser/www
rails demo

Now, log back into root and mod the directory to be read:
exit
chmod 755 /home/newuser

We need to setup the virtual host for this application.  Add these lines at bottom of file:

<VirtualHost *:80>
ServerName www.demo.com
DocumentRoot /home/newuser/www/demo/public
</VirtualHost>

Make sure DocumentRoot points to public directory of your rails application. Also add server name alias to hosts file in /etc/ folder. Now start apache server from console.

service httpd start

Your new rails application should be running now with Phusion Passenger.

3 Comments :, more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!