Phusion Passenger – Deploying Rails on Mac OS X Apache

I’ve been working on learning and developing Rails.  One of the features I enjoyed while doing Grails was the ease in which it took to deploy and run my Grails app in Apache.

I’m sure there are other ways to do this, most were, quite honest way over my head – but I started to investigate options and ran into ‘Phusion Passenger’, a.k.a. mod_rails or mod_rack.  From the website:

Phusion Passenger™ — a.k.a. mod_rails or mod_rack — makes deployment of Ruby web applications, such as those built on the revolutionary Ruby on Rails web framework, a breeze. It follows the usual Ruby on Rails conventions, such as “Don’t-Repeat-Yourself”.

  • Deployment is only a matter of uploading application files. No Ruby (on Rails)-specific server configuration required!
  • Supports both the industry standard Apache web server and the fast and lightweight Nginx web server.
  • Allows Ruby on Rails applications to use about 33% less memory, when used in combination with Ruby Enterprise Edition (optional).
  • Zero maintenance. No port management, server process monitoring or stale file cleanup required. Errors are automatically recovered whenever possible.
  • Designed for performance, stability and security. Phusion Passenger should never crash Apache even in case of crashing Rails applications.
  • Well-documented, for both system administrators and developers!

      The installation (this is for Mac OS X Snow Leopard) – especially the video is very straightforward.

      Let me repeat the steps I went through, because honestly, the Phusion Passenger install was a piece of cake, however, my Apache setup as a Mac OS X user was new to me and so I wanted to share these steps for anyone else like me who might struggle on this part.  I am going to assume you have a Rails app and have made it that far.

      Pre-Install Notes:
      First, you shouldn’t have to install Apache on Snow Leopard, it comes with the OS.  You can check in your System Preferences.


      Select ‘Sharing’:



      (note, you can stop and start Apache by checking/unchecking Web Sharing)

      The last important piece here to understand is ‘where’ Apache lives on your Snow Leopard install.  I’m assuming it’s the same (at least for most of us) – located here:


      Finally, I’m going to highly recommend TextWrangler if you are not a Vi user, TextWrangler is a great (& free!) texteditor for Mac – and it lets you access and alter files that require sudo access, etc…

      Ok, let’s get started.  I suggest you fire up the video link and follow along:

      1. open up Terminal, enter the following to install passenger:

      sudo gem install passenger

      2. next, install the apache2 module:

      sudo passenger-install-apache2-module

      At the end of the install, passenger provides some critical information, ie.


      The text above might differ for your machine, but you need to copy that text to put in your Apache config.

      3. Open up TextWrangler – goto File – Open File by Name (or use terminal for vi):


      4.  Goto the bottom of the file and paste in your contents.  ie.

      LoadModule passenger_module /Library/Ruby/Gems/1.8/gems/passenger-2.2.15/ext/apache2/

         PassengerRoot /Library/Ruby/Gems/1.8/gems/passenger-2.2.15

         PassengerRuby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby

      5. Now, assuming you have the built in Apache install for Snow Leopard – we need to setup virtual hosts

      Goto this line in the httpd.conf and remove the # – it should look like below:

      # Virtual hosts

      Include /private/etc/apache2/extra/httpd-vhosts.conf

      Ok, you are done with httpd.conf – save it

      6. Now we need to add our Virtual host information, open the conf file in TextWrangler:

      ie. /private/etc/apache2/extra/httpd-vhosts.conf

      Check for the following:

      NameVirtualHost *:80  (just validate this is there)

      Comment out the existing <VirtualHost *:80> entries

      Add the following:

      <VirtualHost *:80>

         DocumentRoot "/Library/WebServer/Documents"

         ServerName localhost


      Then add your app – the example would be:

      <VirtualHost *:80>

         DocumentRoot "/Users/stevegentile/Sites/book_shelf/public"

         ServerName book_shelf


      NOTE: above should be the path to your rails app – and the name you want to give the app for it’s URL.  Additionally, it must point to the ‘public’ folder in your rails app!

      7. Ok, we are almost there, now we need to tell our machine how to access the app, so we need to open our hosts file and edit it.    Back to TextWrangler and open file by name:  /private/etc/hosts

      Add a line at the bottom like this example: book_shelf

      This entry should match the ServerName as set above (ie. book_shelf and book_shelf)

      8. Go back to your Web Sharing, uncheck and check to restart Apache (or use the terminal cmd)

      9.  You should be able to enter http://youappname (ie http://book_shelf ) in your browser to view your rails app.


      2 thoughts on “Phusion Passenger – Deploying Rails on Mac OS X Apache

      1. thank you for an amazing guide! everything seems to work up to the point when I actually go to my app in the browser and this is what I get:

        Ruby (Rack) application could not be started
        Error message:
        no such file to load — bundler
        Exception class:

        Did you ever encounter this problem? It looks like passenger can’t find my gems(?)

      Leave a Reply

      Fill in your details below or click an icon to log in: Logo

      You are commenting using your account. Log Out /  Change )

      Google+ photo

      You are commenting using your Google+ account. Log Out /  Change )

      Twitter picture

      You are commenting using your Twitter account. Log Out /  Change )

      Facebook photo

      You are commenting using your Facebook account. Log Out /  Change )


      Connecting to %s