Harmonious Ruby 2.0 and Passenger with Linux Apache

If you are a happy Apache Passenger user you might lose some of that joy when your Rails site looks like this after an upgrade to Ruby 2.0.0.

This was particularly problematic for me since I had recently re-installed Ruby to reside in a personal home .rvm folder for Sudo Free Ruby with RVM.  So I was looking at both a Ruby reconfig and a possible upgrade incompatibility issue. I was seeing 404s when trying to view a Rails Route URi and endless missing Ruby Gem errors.

Here’s what I did to get the joy back, as my Passenger Apache Module is now properly handling Ruby 2.0.0 sites and using the Ruby Gems in my .rvm folder that it’s supposed to be using.

First I installed the latest passenger gem using the pre-release option.

$ gem install passenger –pre

Notice, no sudo.  Next I installed the latest Passenger Apache2 Module with

$ passenger-install-apache2-module

Again, no sudo.  As written in the Phusion Apache User’s Guide, passenger-install-apache2-module is actually just a user-friendly front end around the command rake apache2, which performs the actual compilation of Phusion Passenger.  

When the Passenger Module compile is complete it will provide you with the Apache configuration you’ll need to add to /etc/apache2/apache2.conf. Here’s what that looks like.

When the output says /etc/apache2/apache2.conf, it MEANS /etc/apache2/apache2.config.  That’s important, at least in my experience it is.  I plan on playing around with alternative Passenger load and configuration options for more Ruby Gemset version flexibility in the future, but I’ve found that if you put the Passenger config and load statements in their respective /mods-available/passenger .load and .conf files that Passenger will not load properly and throw up 404s on Rails Routes.

Hope this post restores Passenger and Ruby harmony for fellow Rail Folk after a Ruby 2.0 upgrade.