Passenger 4 with PassengerRuby and different gem set
Asked Answered
T

2

7

I've got a server that predominantly runs Ruby 1.8.7, but now I have a Rails 3.2 app that needs 1.9.3. I've installed Passenger 4 as it supports the ability to run multiple Rubies on a per-virtual server basis.

However, it appears that while you can assign a particular Ruby, the application doesn't have access to that Ruby's gemset. So I have my virtual server configured with the 1.9.3 Ruby, as confirmed on the error page my application now gives:

Ruby interpreter command
/home/aaron/.rvm/rubies/ruby-1.9.3-p0/bin/ruby

But the GEM_HOME parameter tells a different story:

GEM_HOME = /home/aaron/.rvm/gems/ruby-1.8.7-p352

Looking through the configuration directives for Passenger 4, I see no way to specify a different gemset. Am I missing something, or is this thing just not ready for prime time?

Trunkfish answered 23/3, 2013 at 2:32 Comment(2)
Are you deploying with capistrano? By default it installs gems locally, thus completely bypassing the path specified in GEM_HOME. If not a complete solution, might be a viable workaround.Haw
I setup my application to work via Capistrano, but that didn't work. Turns out installing Passenger 4 with Ruby 1.8.7 is the problem. When I run Passenger 4 under 1.9.3 it works fine. But it's a no-go. :-(Trunkfish
W
23

From your gemset dir run:

   $ passenger-config --ruby-command

It will tell you ruby path for Apache and Nginx.

  Command: /home/deric/.rvm/wrappers/ruby-2.0.0-p247@my_gemset/ruby
  Version: ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
  To use in Apache: PassengerRuby /home/deric/.rvm/wrappers/ruby-2.0.0-p247@my_gemset/ruby
  To use in Nginx : passenger_ruby /home/deric/.rvm/wrappers/ruby-2.0.0-p247@my_gemset/ruby

Nginx: For Passenger 4 you can specify multiple ruby versions. So for specific server config:

your_site.conf:

server {
   listen 80;
   root /home/aaron/web/public;
   passenger_enabled on;
   passenger_ruby /home/aaron/.rvm/wrappers/ruby-2.0.0-p247@your_gemset/ruby;
}

nginx.conf: (this works for new passenger 4.0.17)

http {

    passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;

}

Just run from your gemset dir this:

   $ passenger-status

It will check whether passenger_native_support.so is available. Depending on your RVM installation, you might need to run it with rvmsudo

   $ rvmsudo passenger-status

For Debian/Ubuntu there are now binary packages of nginx and passenger available which makes the installation much easier.

Wellnigh answered 13/9, 2013 at 9:33 Comment(0)
J
7

As Tombart pointed out: If you use the precompiled Passenger modules (in my case for for Apache2) you end up with a system up and running.

However, if using RVM I stumbled upon the fact that you need to use the "wrapper directory" to select the correct RVM ruby version and gemet like so in your Apache vhost config:

PassengerRuby /home/of_your_ruby_user/.rvm/wrappers/ruby-x.y.z-p123@gemset/ruby

This way Passenger knows how to find the correct gemset relative to this directory (../../gems/ruby-x.y.z-p123@gemset/gems). Otherwise Passenger would use the "standard ruby gemset" which is odd if you want to run multiple apps with the same ruby version. I can only guess that this is similar for Nginx.

Jennettejenni answered 23/10, 2013 at 7:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.