VPS apache config – 添加最新的乘客gem后,命令’PassengerDefaultRuby’无效
曾经在我的vps中有这个ruby列表:
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上安装了一个新的应用程序,所以我将2.0添加到rvm
:
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 ]
安装了passenger
和passenger-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,重启后我收到此错误 :
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
查找它。 这是为什么? 感谢您的任何帮助。
得到它了!
您需要在根级别分配默认的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
:
PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p194/ruby ServerName mysite.md DocumentRoot /home/apps/myapp/public AllowOverride None Options -MultiViews
对于适用于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 / …