Last updated

Running a different ruby with Passenger 3.2 and RVM

Passenger 3.2 will have quite some nice new features. 1 2

The features I’m looking forward to most is the ability to specify - per virtual server - which ruby to use.

Before, you installed passenger and specified the required ruby version using passenger_ruby, like this in your nginx.conf:

http {
   passenger_root /opt/passenger;
   passenger_ruby /usr/local/bin/ruby;

   server {
     server_name ariejan.net;
     passenger_enabled on;
  }
}

Now, if you added another server it would be forced to use the same ruby version. This might be okay for most servers, but for me not so much. I have several side-projects running on a single machine, and using only one ruby version is not optimal or even impossible.

Now, with the upcoming Passenger 3.2 you can select a ruby version per server. This is awesome. All you have to do is move the passenger_rubydirective into the server block and all is set. Of course, you can leave the globally set ruby just as is.

http {
   passenger_root /opt/passenger;
   passenger_ruby /usr/local/bin/ruby;

   server {
     server_name ariejan.net;
     passenger_enabled on;
     passenger_ruby /home/deployer/.rvm/rubies/ruby-1.9.3-p194/bin/ruby;
  }
}

As you can see in the example above, I’m referencing ruby-1.9.3-p194, installed with RVM.

Installing “experimental” Passenger

The installation is easy, as usual, but you must checkout the passenger source from Github and use the experimental branch.

Warning: do not install the experimental branch of Passenger on your production server unless you are absolutely sure what you’re doing and you know how to rollback quickly and easily to a stable version of passenger.

cd /opt
git clone https://github.com/FooBarWidget/passenger.git
cd /opt/passenger
git checkout -b experimental origin/experimental
./bin/passenger-install-nginx-module