7

Running a different ruby with Passenger 3.2 and RVM

 3 years ago
source link: https://www.devroom.io/2012/05/11/running-a-different-ruby-with-passenger-3-2-and-rvm/?utm_campaign=Feed%3A+ariejan+%28ariejan%7Cdevroom.io%29
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Running a different ruby with Passenger 3.2 and RVM

Posted: 2012-05-11 - Last updated: 2019-06-05

Tagged ruby rvm passenger nginx

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

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK