Everyday Rails

Passenger 3, RVM, and Apache; quick and easy

By Aaron Sumner, January 25, 2011.

Passenger 3 has been out since last October, so for most folks this will all be very, very old news. For those of you who haven’t upgraded yet, version 3 touts faster, more stable performance over version 2. It’s also very easy to set up on your development computer so you can have multiple Rails projects running in development simultaneously. For my setup I’m also using RVM to manage project-specific gemsets (read more about why I think this is a great idea), but standardizing on one Ruby version.

To start, it probably wouldn’t hurt to make sure you’ve got the latest version of RVM on your computer. At this writing, that’s version 1.2.4. The following should take care of the upgrade:

  $ rvm update
  $ rvm reload

Next, install the new Passenger gem (at 3.0.2 as I write this). This is very well documented on the RVM website, if you need more detail. I keep the Passenger gem in my @global RVM gemset.

  $ gem install passenger

Now run the Passenger module installer:

  $ rvm passenger-install-apache2-module

(Note: Earlier I’d incorrectly listed the above command as rvmsudo. This isn’t necessary. Thank you to Oldřich Vetešník for pointing this out.)

Follow the instructions, including making sure you copy the Apache configuration directives provided into your own Apache config files. The good news here is these lines already point to your RVM-specified Ruby (the Ruby you were using when you installed the Passenger gem), so Apache is all set.

Also note the suggested virtual host configuration provided; you may need it later depending on whether you’ve been using Passenger before or are using any supporting utilities for Passenger.

**Potential gotcha with Apache 2 in Mac OS X 10.6.6:** When I rebooted Apache following the Passenger module installer, I was greeted with an error in the `apachectl` script. The suggestion in [this post](http://articles.itecsoftware.com/shell-scripting/fix-for-mac-os-10-6-5-apachectl-line-82-ulimit) solved the issue for me.

From here, it’s just a matter of preparing your Rails applications to take advantage of RVM’s gemsets feature. Again, I’ll refer you to an earlier post about adding a setup_load_paths.rb file to each new app’s config directory. You’ll also need to set up a virtual host for each new app. If you were using Passenger 2.2.x before, your existing virtual hosts should work fine. (The OS X Passenger Preference Pane, while still only 32-bit, is still working for me on my setup.)

What about multiple Rubies?

I haven’t done this myself, but if you need to use this general setup with multiple versions of Ruby, refer to this post on Phusion’s blog about using proxies with Passenger and RVM

Discussion

Follow along on on Mastodon, Facebook, or Bluesky to keep up-to-date with my latest posts. Better yet, subscribe to my newsletter for updates from Everyday Rails, book picks, and other thoughts and ideas that didn't quite fit here.
Buy Me A Coffee

Test with confidence!

If you liked my series on practical advice for adding reliable tests to your Rails apps, check out the expanded ebook version. Lots of additional, exclusive content and a complete sample Rails application.

Newsletter

Ruby on Rails news and tips, and other ideas and surprises from Aaron at Everyday Rails. Delivered to your inbox on no particular set schedule.