2011-04-15 46 views
1

我有相同的服务器上运行两个网站。两者都使用乘客和rvm。每个网站都有一个独特的rvm gemset。我遇到的问题是我怎么会设置乘客apache的启动。如何从RVM和独特的宝石阿帕奇加载乘客设置

这里是我的Apache配置的乘客:

[email protected]:/etc/apache2/mods-enabled$ ls passenger.* 
passenger.conf passenger.load 

[email protected]:/etc/apache2/mods-enabled$ cat passenger.conf 
PassengerRoot /home/ubuntu/.rvm/gems/[email protected]/gems/passenger-3.0.2 
PassengerRuby /home/ubuntu/.rvm/wrappers/[email protected]/ruby 

[email protected]:/etc/apache2/mods-enabled$ cat passenger.load 
LoadModule passenger_module /home/ubuntu/.rvm/gems/[email protected]/gems/passenger-3.0.2/ext/apache2/mod_passenger.so 

您可以从上面看到的,我已经配置了Apache装载乘客模块/从[email protected] RVM宝石组配置。我的问题在于有我的其他网站的额外宝石集,[email protected]。我也想过,在全球创业板的集装乘客,但我认为这将看到的问题时,它会尝试加载宝石独特的到我的项目的具体宝石套。

这里是我对每个项目安装宝石:

[email protected]:/etc/apache2/mods-enabled$ rvm use [email protected] 
Using /home/ubuntu/.rvm/gems/ruby-1.8.7-p334 with gemset snowcrash 
[email protected]:/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) 

[email protected]:/etc/apache2/mods-enabled$ rvm use [email protected] 
Using /home/ubuntu/.rvm/gems/ruby-1.8.7-p334 with gemset pixel-pets 
[email protected]:/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) 

回答

2

来源:https://rvm.beginrescueend.com/integration/passenger/

在你.rvmrc做:

if [[ -s "/Users/sutto/.rvm/environments/[email protected]" ]] ; then 
    . "/Users/sutto/.rvm/environments/[email protected]" 
else 
    rvm --create use "[email protected]" 
fi 

,或只与创建它:

cd path/to/project && rvm use [email protected] --rvmrc --create 

然后在每个轨道项目,添加一个新的文件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 

当然,你应该更换/Users/sutto/.rvm你RVM路径,并通过[email protected]正确的宝石。

+0

谢谢,巴勃罗。这工作,但必须为每个项目创建一个config/setup_load_paths.rb。还可以使用cd〜/ snowcrash /&& rvm使用[email protected] --rvmrc --create为_each_项目目录创建.rvmrc。 – sybind 2011-04-16 17:28:36