2

How can I use Passenger, RVM and Apache with 1.9 and 1.8(ree) ruby version? I need it in production env. I try this: RVM PASSENGER but REE is only working. 1.9 say this:

The given ruby environment requires ruby-1.9.2-p318 (versus ree-1.8.7-2012.02) (RVM::IncompatibleRubyError)

My files from 1.9 ruby version: .rvmrc

environment_id="ruby-1.9.2-p318"

if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
  && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
then
  \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
  [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
    \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
  if [[ $- == *i* ]] # check for interactive shells
  then echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" 
  else echo "Using: $GEM_HOME" 
  fi
else
  rvm --create use  "$environment_id" || {
    echo "Failed to create RVM environment '${environment_id}'."
    return 1
  }
fi

setup_load_paths.rb

if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
    begin
      rvm_path     = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
      rvm_lib_path = File.join(rvm_path, 'lib')
      require 'rvm'
      RVM.use_from_path! File.dirname(File.dirname(__FILE__))
    rescue LoadError
      # RVM is unavailable at this point.
      raise "RVM ruby lib is currently unavailable."
    end
  end

  ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__))
  require 'bundler/setup'

httpd.conf

...
LoadModule passenger_module /usr/local/rvm/gems/ree-1.8.7-2012.02/gems/passenger-3.0.12/ext/apache2/mod_passenger.so
   PassengerRoot /usr/local/rvm/gems/ree-1.8.7-2012.02/gems/passenger-3.0.12
   PassengerRuby /usr/local/rvm/wrappers/ree-1.8.7-2012.02/ruby

...
quatermain
  • 1,442
  • 2
  • 18
  • 33
  • 1
    for now passenger does not support running multiple rubies, they have released beta build of 3.2 which might support it. – mpapis May 04 '12 at 19:16
  • Do you know some other solutions for using two versions of ruby pleas? – quatermain May 07 '12 at 08:06
  • 2
    check this http://serverfault.com/questions/368695/best-practice-rvm-w-multiple-nginx-passsenger-standalone-servers-running-one-a – mpapis May 07 '12 at 13:57

1 Answers1

0

You may checkout this awesome article: Phusion Passenger & running multiple Ruby versions

Basically, you could use rvm and reverse proxy to get it done. For example, you could deploy one ruby version (like 1.9) as usual, and use reverse proxy to setup the other one:

  • rvm use 1.8
  • gem install passenger --pre
  • cd /path/to/your/app
  • passenger start -a 127.0.0.1 -p 3000 -d
  • setup reverse proxy in your apache config

    <VirtualHost *:80>
      ServerName www.hamburgers.com
      DocumentRoot /path/to/your/app/public
      PassengerEnabled off
      ProxyPass / http://127.0.0.1:3000
      ProxyPassReverse / http://127.0.0.1:3000
    </VirtualHost>
    

you could also try use unicorn instead of passenger, or replace apache with ngix.

KilenZhang
  • 21
  • 3