PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, September 21, 2022

[FIXED] How can I run two run two passenger servers behind one apache instance?

 September 21, 2022     apache, passenger, ruby, ruby-on-rails, virtualhost     No comments   

Issue

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.


Solution

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?



Answered By - TomD
Answer Checked By - Clifford M. (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing