【问题标题】:VPS apache config - Invalid command 'PassengerDefaultRuby' after adding latest passenger gemVPS apache config - 添加最新乘客 gem 后命令“PassengerDefaultRuby”无效
【发布时间】:2013-10-06 21:22:12
【问题描述】:

曾经在我的 vps 中有这个红宝石列表:

   ruby-1.9.2-p320 [ i686 ]
=* ruby-1.9.3-p194 [ i686 ]
   ruby-1.9.3-p374 [ i686 ]
   ruby-1.9.3-p392 [ i686 ]

今天我在ruby 2.0的这个vps上安装了一个新应用,所以我在rvm上加了2.0:

   ruby-1.9.2-p320 [ i686 ]
   ruby-1.9.3-p194 [ i686 ]
   ruby-1.9.3-p374 [ i686 ]
   ruby-1.9.3-p392 [ i686 ]
=* ruby-2.0.0-p247 [ i686 ]

安装了passengerpassenger-apache-module,说明说要添加这些行:

   LoadModule passenger_module /usr/local/rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.19/buildout/apache2/mod_passenger.so
   PassengerRoot /usr/local/rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.19
   PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-2.0.0-p247/ruby

/etc/apache2/apache2.conf 并重启apache,重启后我得到了这个error

Syntax error on line 242 of /etc/apache2/apache2.conf:
Invalid command 'PassengerDefaultRuby', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.
   ...fail!

还有一个问题,当我在http://nccm.md 打开我的应用程序时,我得到了:

Could not find rake-10.1.0 in any of the sources (Bundler::GemNotFound)

gem list 命令我可以看到这个gem 安装在ruby 2.0 环境中,但应用程序在usr/local/rvm/gems/ruby-1.9.3-p194@global 中查找它。这是为什么?感谢您的帮助。

【问题讨论】:

  • 我加入了这些问题。我有同样的问题,但我使用的是 nginx 服务器。旧应用程序在 1.9.3 版本上运行。 2.0.0 上的新应用。当我在 Gemfile 中更改 ruby​​ 版本并将旧应用程序中的 deploy.rb 更改为 2.0.0 时,它可以工作,但我不想在所有应用程序中都这样做。
  • @KRH - 解决了,看看

标签: ruby apache2 rvm passenger vps


【解决方案1】:

知道了!

您需要在根级别分配一个默认 ruby​​,其他的将在 sites-enabled 配置文件中设置。例如,在我的apache2.conf 文件中:

   LoadModule passenger_module /usr/local/rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.19/buildout/apache2/mod_passenger.so
   PassengerRoot /usr/local/rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.19
   PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-2.0.0-p247/ruby

然后在/etc/apache2/sites-enabled/mysite 中启动应该在ruby-1.9.3 中运行的应用程序,我将添加PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p194/ruby

<VirtualHost xxx.xx.xx.xx:80>
  PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p194/ruby
  ServerName mysite.md
  DocumentRoot /home/apps/myapp/public
  <Directory /home/apps/myapp>
     AllowOverride None
     Options -MultiViews
  </Directory>
</VirtualHost>

对于使用ruby-2.0 的应用,无需添加PassengerRuby 选项,因为ruby-2.0 现在是默认选项。

另外,如果您在 apache2.config 文件中加载了其他 rvm 乘客模块,就像我的情况一样:

#   LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.18/ext/apache2/mod_passenger.so
#   PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.18
#   PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p194/ruby

您需要像我一样删除它们或评论它们,因为您将在 /etc/apache2/sites-enabled/mysite 配置文件中加载 ruby​​ 版本。

注意!

这仅适用于乘客 > 4.0.0。我已经对此进行了测试 乘客 3.0.8 并且它不起作用。请注意,PassengerDefaultRuby 在乘客版本 4.0.0 中引入,请参阅 modrails.com/documentation/….

【讨论】:

  • 这仅适用于乘客 > 4.0.0。我已经在乘客 3.0.8 上对此进行了测试,但它不起作用。请注意,PassengerDefaultRuby 是在乘客版本 4.0.0 中引入的,请参阅 modrails.com/documentation/...。
  • @Rupert,你是对的,谢谢你的评论。忘了提这个,因为我和乘客 4 正好有这个问题。
猜你喜欢
  • 2013-12-04
  • 2011-11-03
  • 2012-12-07
  • 2017-09-26
  • 2016-09-01
  • 2011-06-18
  • 1970-01-01
  • 1970-01-01
  • 2015-10-25
相关资源
最近更新 更多