1

In order to run passenger behind apache, these two directives are needed:

PassengerRoot
PassengerDefaultRuby

These two have a 'server config' context according to documentation here. Which means Apache is only able to set one ruby version and one passenger root for the entire server instance. Since, I have two ruby versions running using RVM and each Rails instance is running in its own virtual host context, is there a way to set PassengerRoot and PassengerDefaultRuby per virtual host ?

PS: Hack-ish solutions are also acceptable.

Rorchackh
  • 2,113
  • 5
  • 22
  • 38

1 Answers1

1

Not sure why would you need to set different PassengerRoot. You shouldn't need to do that, Passenger root can be on any ruby version really and it will just work. You should only need to set PassengerRuby in virtual host.

We've got Rails setup with multiple Ruby versions/gemsets per project set through RVM and we just set PassengerRuby like:

<VirtualHost *:80>
  PassengerRuby /usr/local/rvm/gems/ruby-2.3.0@tomproject/wrappers/ruby
...
</VirtualHost>

Just make sure to point PassengerRuby to your relevant wrapper in RVM gemset.

For reference this is my passenger.conf (Passenger was built on ruby 2.1.1)

LoadModule passenger_module /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-enterprise-server-5.0.21/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
 PassengerRoot /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-enterprise-server-5.0.21
 PassengerDefaultRuby /usr/local/rvm/gems/ruby-2.1.1/wrappers/ruby
    PassengerStatThrottleRate 0

    # PassengerMaxPoolSize
    # Default: 6
    # For 2gb RAM: 30
    # For 256 slice with MySQL running: 2
    PassengerMaxPoolSize 12

    PassengerMinInstances 0
    PassengerPoolIdleTime 300
    PassengerMemoryLimit 400
</IfModule>

One thing though - if you've got Passenger installed per gemset - don't. Install it globally in the default ruby version. Will save you a headaches later. It can still work but it's just no the best practice.

More info here: https://www.phusionpassenger.com/library/install/apache/install/oss/rubygems_rvm/#i-have-multiple-ruby-versions-or-gemsets.-does-it-matter-which-one-i-use-to-install-passenger-with?

TomD
  • 781
  • 4
  • 17
  • This does the job. Thanks mate. I'm okay with using the same passenger installation for all my rubies projects. – Rorchackh Jul 21 '17 at 11:50