2012-05-02 34 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> 
相關問題