如何用rvm和唯一的宝石集从Apache装载乘客

|| 我有两个在同一服务器上运行的网站。两者都使用passenger和rvm。每个网站都有一个独特的rvm gemset。我遇到的问题是如何配置乘客以在Apache中启动。 这是我的Apache乘客配置:
ubuntu@www01:/etc/apache2/mods-enabled$ ls passenger.*
passenger.conf  passenger.load

ubuntu@www01:/etc/apache2/mods-enabled$ cat passenger.conf 
PassengerRoot /home/ubuntu/.rvm/gems/ruby-1.8.7-p334@snowcrash/gems/passenger-3.0.2
PassengerRuby /home/ubuntu/.rvm/wrappers/ruby-1.8.7-p334@snowcrash/ruby

ubuntu@www01:/etc/apache2/mods-enabled$ cat passenger.load 
LoadModule passenger_module /home/ubuntu/.rvm/gems/ruby-1.8.7-p334@snowcrash/gems/passenger-3.0.2/ext/apache2/mod_passenger.so
从上面可以看到,我已配置apache从ruby-1.8.7-p334@snowcrash rvm gem set加载乘客模块/配置。我的问题在于为我的其他网站设置了另一个宝石,ruby-1.8.7-p334 @ pixel-pets。我已经考虑过在全球宝石集中安装乘客,但是我认为当它尝试加载我的项目特定宝石集所特有的宝石时,会遇到问题。 这是我为每个项目安装的gem:
ubuntu@www01:/etc/apache2/mods-enabled$ rvm use 1.8.7@snowcrash
Using /home/ubuntu/.rvm/gems/ruby-1.8.7-p334 with gemset snowcrash
ubuntu@www01:/etc/apache2/mods-enabled$ gem list -l

*** LOCAL GEMS ***

actionmailer (2.3.11)
actionpack (2.3.11)
activerecord (2.3.11)
activeresource (2.3.11)
activesupport (2.3.11)
daemon_controller (0.2.6)
fastthread (1.0.7)
file-tail (1.0.5)
haml (3.0.25)
hpricot (0.8.4)
mysql (2.8.1)
passenger (3.0.2)
rack (1.1.2)
rails (2.3.11)
rake (0.8.7)
spruz (0.2.5)

ubuntu@www01:/etc/apache2/mods-enabled$ rvm use 1.8.7@pixel-pets
Using /home/ubuntu/.rvm/gems/ruby-1.8.7-p334 with gemset pixel-pets
ubuntu@www01:/etc/apache2/mods-enabled$ gem list -l

*** LOCAL GEMS ***

actionmailer (2.3.8)
actionpack (2.3.8)
activerecord (2.3.8)
activeresource (2.3.8)
activesupport (2.3.8)
backports (1.18.2)
border_patrol (0.1.0)
bson (1.3.0, 1.1.1)
bson_ext (1.3.0, 1.1.1)
faker (0.3.1)
jnunemaker-validatable (1.8.4)
mongo (1.1.1)
mongo_mapper (0.8.6)
nokogiri (1.4.3.1)
plucky (0.3.7)
rack (1.1.2)
rails (2.3.8)
rake (0.8.7)
will_paginate (2.3.12)
    
已邀请:
来自:https://rvm.beginrescueend.com/integration/passenger/ 用你的
.rvmrc
做:
if [[ -s \"/Users/sutto/.rvm/environments/ree-1.8.7-2010.02@my-app-name\" ]] ; then
  . \"/Users/sutto/.rvm/environments/ree-1.8.7-2010.02@my-app-name\"
else
  rvm --create use  \"ree-1.8.7-2010.02@my-app-name\"
fi
或仅使用以下命令创建它:
cd path/to/project && rvm use ree-1.8.7-2010.02@my-app-name --rvmrc --create
然后在每个Rails项目中,添加一个新文件
config/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\')
    $LOAD_PATH.unshift rvm_lib_path
    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

# Select the correct item for which you use below.
# If you\'re not using bundler, remove it completely.
#
# # If we\'re using a Bundler 1.0 beta
# ENV[\'BUNDLE_GEMFILE\'] = File.expand_path(\'../Gemfile\', File.dirname(__FILE__))
# require \'bundler/setup\'
#
# # Or Bundler 0.9...
# if File.exist?(\".bundle/environment.rb\")
#   require \'.bundle/environment\'
# else
#   require \'rubygems\'
#   require \'bundler\'
#   Bundler.setup
# end
当然,您应该用rvm路径替换
/Users/sutto/.rvm
,并用正确的gemset替换
ruby-1.8.7-p334@snowcrash
。     

要回复问题请先登录注册