简体   繁体   English

具有两个Ruby版本的RVM和Passenger

[英]RVM and Passenger with two Ruby versions

How can I use Passenger, RVM and Apache with 1.9 and 1.8(ree) ruby version? 如何在1.9和1.8(ree)ruby版本中使用Passenger,RVM和Apache? I need it in production env. 我在生产环境中需要它。 I try this: RVM PASSENGER but REE is only working. 我尝试这样: RVM PASSENGER但REE仅能正常工作。 1.9 say this: 1.9这样说:

The given ruby environment requires ruby-1.9.2-p318 (versus ree-1.8.7-2012.02) (RVM::IncompatibleRubyError) 给定的ruby环境需要ruby-1.9.2-p318(相对ree-1.8.7-2012.02)(RVM :: IncompatibleRubyError)

My files from 1.9 ruby version: .rvmrc 我的1.9 ruby​​版本的文件:.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 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 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

...

You may checkout this awesome article: Phusion Passenger & running multiple Ruby versions 您可以查看这篇很棒的文章: Phusion Passenger和运行多个Ruby版本

Basically, you could use rvm and reverse proxy to get it done. 基本上,您可以使用rvm和反向代理来完成它。 For example, you could deploy one ruby version (like 1.9) as usual, and use reverse proxy to setup the other one: 例如,您可以照常部署一个红宝石版本(如1.9),并使用反向代理来设置另一个版本:

  • rvm use 1.8 rvm使用1.8
  • gem install passenger --pre 宝石安装乘客--pre
  • cd /path/to/your/app cd / path / to / your / app
  • passenger start -a 127.0.0.1 -p 3000 -d 乘客启动-a 127.0.0.1 -p 3000 -d
  • setup reverse proxy in your apache config 在您的apache配置中设置反向代理

     <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. 您也可以尝试使用独角兽代替乘客,或用ngix代替apache。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM