2012-05-02 37 views
0

我试图配置Apache V2以使用VirtualHost指令同时处理两个Rails(3.2.2)应用程序。我在本地笔记本电脑上做这个。 (Ubuntu,Ruby 1.9.2和Passenger 3.0.12。)如何使用共享Passenger Gem在Apache2上启动多个Rails应用程序?

使用“Agile Web Development .... Rails”,V4中的部署说明。第一个简单的应用程序启动无w/o问题。

然后,我创建了第二个具有非常相似特征的简单应用程序。用第二个VirtualHost指令编辑/etc/apache2/apache2.conf,编辑/ etc/hosts将第二个指定的URL映射到相同的127.0.0.1地址。

重启动Apache炸毁如下所示:

apache2的:上/etc/apache2/apache2.conf中的240行语法错误:无法加载/home/bubby/.rvm/gems/ruby-1.9.2 -p180/gems/passenger-3.0.12/ext/apache2/mod_passenger.so到服务器中:/home/bubby/.rvm/gems/ruby-1.9.2-p180/gems/passenger 3.0.12/ext/apache2/mod_passenger.so:无法打开共享目标文件:没有此类文件或目录

这两个应用程序都与Passenger捆绑在一起。 “找到mod_passenger.so”返回正确的位置。有一个更好的方法吗?

+0

那么apache2.conf的相关内容是什么样的? –

回答

0

做文件

/home/bubby/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.12/ext/apache2/mod_passenger.so 

真的存在,它是可读的Apache?

+0

嗯 - 没有.rvm目录。桌子上的额头>。 –

0

这是我怎么设置多个virtualhosts客运:

[email protected]:# cat /etc/apache2/mods-enabled/passenger.conf 
<IfModule mod_passenger.c> 
    PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11 
    PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p125/ruby 
</IfModule> 

[email protected]:# cat /etc/apache2/mods-enabled/passenger.load 
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/ext/apache2/mod_passenger.so 


[email protected]:# cat /etc/apache2/sites-enabled/site1 
<VirtualHost *:80> 
    ServerName site1 
    RailsEnv development 

    DocumentRoot /var/www/site1/public 
    <Directory /var/www/site1/public> 
    Options None 
    AllowOverride None 

    Order deny,allow 
    Allow from all 
    </Directory> 
</VirtualHost> 


[email protected]:# cat /etc/apache2/sites-enabled/site2 
<VirtualHost *:80> 
    ServerName site2 
    RailsEnv development 

    DocumentRoot /var/www/site2/public 
    <Directory /var/www/site2/public> 
    Options None 
    AllowOverride None 

    Order deny,allow 
    Allow from all 
    </Directory> 
</VirtualHost> 
0

肯定。

对于生产,通过将sudo添加到安装命令,在系统范围模式而不是用户模式下安装rvm。在开发中,您可以保持用户模式。

在您指定的红宝石的全球宝石镶嵌中安装乘客宝石。做相同的宝石运行在服务器中安装apache-乘客国防部命令复制生成的MOD装载

再到之后,这将是用户通过多个应用程序(记住每一个宝石版本要求)

得到正确的宝石加载该文件添加到您的config文件夹

# setup_load_path.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__)) 
    # edit this line according to you ruby version 
    RVM.use!('[email protected]_GEMSET') 
    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 

后,只是让Apache指向正确的公共目录

DocumentRoot /var/www/app/public 
    <Directory /var/www/app/public> 
相关问题