Installing Phusion Passenger on CentOS 5.5

Need to run Rails apps under Apache?  Phusion’s Passenger is becoming the de-facto standard for doing so with its ease of setup, low memory footprint, and deep support.  Once you have Ruby and Rails setup on your CentOS server (see this post), you can install Passenger and integrate it with Apache.  Here’s how:

1) Install the Apache development tools
Passenger is nothing more than a dynamic shared object (DSO).  You will need the httpd-devel package to build Dynamic Shared Objects (DSOs) for Apache.  The following command will install it:

yum install httpd-devel

Depending on your server, you will notice a number of dependent packages being installed, including apr-devel, perl, and apr-util-devel.

2) Install Passenger.
Passenger is a gem, and installed in the typical fashion of any gem:

gem install passenger
Building native extensions.  This could take a while...
Building native extensions.  This could take a while...
Successfully installed fastthread-1.0.7
Successfully installed passenger-2.2.15
2 gems installed
Installing ri documentation for fastthread-1.0.7...
Installing ri documentation for passenger-2.2.15...
Installing RDoc documentation for fastthread-1.0.7...
Installing RDoc documentation for passenger-2.2.15...

3) Build Passenger for Apache
Passenger has a scripted installer. Start it with this command:


The first thing it will do is check its own dependencies. If you have everything in place, you will see this:

Follow the onscreen keyboard prompts from the script, and you will see build messages scroll quickly by as the binaries are built. If the build is successful, you will be presented with this final screen before the shell script exits:

4) Integrate Passenger with Apache
Before beginning, make a copy of your Apache httpd.conf file:

cp /etc/httpd/conf/httpd.conf httpd.conf.orig

Then edit the httpd.conf file and search for the LoadModules section. Add a directive at the end of this list to load the Passenger shared object. It should look like this:

Now scroll down to the end of the file, and add these lines to help the Passenger shared object find the ruby and gem binaries:

PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-2.2.15
PassengerRuby /usr/local/bin/ruby

5) Add a symlink to your app
Change to the directory specified by the server-wide DocumentRoot directive (/var/www/html) and add a symlink to your Rails application. In this case, our Rails application lives in the /webapps/todos directory, so the symlink should link to the “public” directory of the application:

ln -s /webapps/todos/public/ todos

6) Add a virtual host directive for your Rails application
Point Apache to your Rails application:

    ServerName localhost
    DocumentRoot /var/www/html
    RailsEnv development
        Allow from all
        Options -MultiViews
     RailsBaseURI /todos

Now restart Apache with an “apachectl restart” command, and browse to your Rails app.  That’s it!

2 Replies to “Installing Phusion Passenger on CentOS 5.5”

Leave a Reply

Your email address will not be published. Required fields are marked *