添加具有不同Ruby和Passenger版本的第二个虚拟主机

时间:2015-02-15 13:00:25

标签: ruby-on-rails ruby apache deployment passenger

我有主要的Rails应用程序在系统Ruby和Passanger上工作。以下虚拟主机工作正常:

<VirtualHost x.x.x.x:80>
  ServerName domain.com

  DocumentRoot /home/john/apps/main_app/public

  PassengerRoot /var/lib/gems/1.9.1/gems/passenger-4.0.29
    PassengerRuby /usr/bin/ruby

  <Directory /home/deploy/apps/main_app/public>
    PassengerEnabled On
    AllowOverride All
    Require all granted
    Options -MultiViews
  </Directory>
</VirtualHost>

现在我想为我的第二个应用程序添加第二个虚拟主机,在不同的Ruby / Passanger版本和不同的域上工作,但在同一台机器上:

<VirtualHost x.x.x.x:80>
  ServerName domain2.com
  DocumentRoot /home/deploy/apps/app/public
  PassengerRoot /home/deploy/.rvm/gems/ruby-2.1.5@app/gems/passenger-4.0.59
  PassengerRuby /home/deploy/.rvm/rubies/ruby-2.1.5/bin/ruby

  <Directory /home/deploy/apps/app/public>
    PassengerEnabled On
    AllowOverride All
    Require all granted
    Options -MultiViews
  </Directory>
</VirtualHost>

启用第二个VirtualHost后,第一个(主应用程序)不再有效。在浏览器中我有403错误。第二个应用的情况相同。

主应用程序的错误日志:

[Sun Feb 15 13:29:08.596451 2015] [autoindex:error] [pid 53380] [client x.x.x.x] AH01276: Cannot serve directory /home/john/apps/main_app/public: 
No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) 
found, and server-generated directory index forbidden by Options directive, referer: x

首先禁用第二个应用后,其中一个正在运行。如何在同一时间内同时使用这两个应用程序?

1 个答案:

答案 0 :(得分:1)

配置不正确。这两个虚拟主机使用两个不同的Passenger版本,并加载两个不同的Ruby版本。

<VirtualHost x.x.x.x:80>
  PassengerRoot /var/lib/gems/1.9.1/gems/passenger-4.0.29
  PassengerRuby /usr/bin/ruby
</VirtualHost>

VS

<VirtualHost x.x.x.x:80>
  PassengerRoot /home/deploy/.rvm/gems/ruby-2.1.5@app/gems/passenger-4.0.59
  PassengerRuby /home/deploy/.rvm/rubies/ruby-2.1.5/bin/ruby
</VirtualHost>