Installing mod_rails in Apache2

Phusion Passenger, a.k.a. mod_rails, is a Ruby on Rails server integrated tightly with apache.  Here is what I did to get it working on Mac OS X.

 Make sure you have gcc – on my Mac OS X system, the easiest way to get this is to install XCode tools.

sudo gem install passenger

Per the install instructions for Passenger, edit httpd.conf and add the following.  For neatness’ sake, I added the IfModule statements:

LoadModule passenger_module /Library/Ruby/Gems/1.8/gems/passenger-2.0.3/ext/apache2/mod_passenger.so
# Adding declarations for mod_rails (a.k.a. Passenger).
<IfModule mod_passenger.c>
        PassengerRoot /Library/Ruby/Gems/1.8/gems/passenger-2.0.3
        PassengerRuby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
</IfModule>

Then to get mod_rails to notice your rails application, inside the VirtualServer statement for your site, if you want the whole site to be served by Rails, just point the DocumentRoot at the ‘public’ folder of your Rails application.  If you want your Rails application to be at a sub-URI of the main site, symlink that sub-URI to your Rails application (which can be completely outside the site content folders), then add the following for that URI (e.g. /blog):

RailsBaseURI /blog

1 comment to Installing mod_rails in Apache2

  • sam

    Also added PassengerPoolIdleTime 0 to httpd.conf to speedup page load on my infrequently used site, and RailsEnv production to the site .conf for completeness.

You must be logged in to post a comment.