简体   繁体   English

如何使用Apache / Passenger和多个Ruby版本运行Rails应用

[英]How to run Rails app using Apache/Passenger with Multiple Ruby versions

I'm trying to setup a Apache/Passenger configuration to allow multiple Ruby versions. 我正在尝试设置Apache / Passenger配置以允许多个Ruby版本。 I saw the post on multiple Rubies here ( http://blog.phusion.nl/2013/08/19/phusion-passenger-4-0-14-released/ ) but apparently it's obsolete as Passenger now supports the "PassengerRuby" config in a Virtual Host. 我在这里看到了多个红宝石上的帖子( http://blog.phusion.nl/2013/08/19/phusion-passenger-4-0-14-released/ ),但显然已经过时了,因为Passenger现在支持“ PassengerRuby”虚拟主机中的配置。 However, I'm still having troubles. 但是,我仍然遇到麻烦。 What am I doing wrong? 我究竟做错了什么?

I have an installation of Passenger (4.0.14) which is configured with 我有一个配置为的Passenger(4.0.14)安装

PassengerDefaultRuby /usr/local/rvm/rubies/ree-1.8.7-2012.02/bin/ruby

The server has a virtual host which has been recently upgraded to include some features which are only available in more recent versions of Rails.. so I'm trying to run Ruby 1.9.3 and Rails 3.0 for just that application. 该服务器具有一个虚拟主机,最近已对其进行了升级,以包括仅在最新版本的Rails中可用的某些功能。因此,我正在尝试仅针对该应用程序运行Ruby 1.9.3和Rails 3.0。

EDIT: The application needs 1.9.3 for some specific features. 编辑:该应用程序需要1.9.3的某些特定功能。 But when I run it with just the PassengerDefaultRuby as 1.8.7 it works fine (except for those features). 但是,当我仅将PassengerDefaultRuby作为1.8.7运行时,它就可以正常工作(这些功能除外)。 It's only when I add 1.9.3 that I have problems. 只有当我添加1.9.3时,我才会遇到问题。

EDIT: If I specify 1.9.3 as the default Ruby, and don't specify a PassengerRuby for the application, the app doesn't work. 编辑:如果我将1.9.3指定为默认Ruby,并且未为该应用程序指定PassengerRuby,则该应用程序将无法运行。 So I'd guess I have something wrong with the 1.9.3 installation. 所以我想我的1.9.3安装有问题。

So.. I add 所以..我加

PassengerRuby /usr/local/rvm/rubies/ruby-1.9.3-p448/bin/ruby

When I do that, I get the following stack track in the apache2 error.log 当我这样做时,我在apache2 error.log中获得以下堆栈跟踪

[ 2013-09-06 07:48:32.2794 32582/7f4d0715c700 Pool2/Spawner.h:738 ]: [App 32622 stdout] 
[ 2013-09-06 07:48:35.6479 32582/7f4d0711b700 Pool2/Implementation.cpp:1172 ]: [App 32622 stderr] [     2013-09-06 07:48:35.6477 32622/0x00000002c633e0(Worker 1) utils.rb:71 ]: *** Exception TypeError in Passenger RequestHandler's client socket (wrong argument type Array (expected Struct)) (process 32622, thread 0x00000002c633e0(Worker 1)):
[ 2013-09-06 07:48:35.6479 32582/7f4d0711b700 Pool2/Implementation.cpp:1172 ]: [App 32622 stderr]   from /usr/lib/ruby/gems/1.8/gems/passenger-4.0.14/lib/phusion_passenger/ruby_core_enhancements.rb:81:in `writev2'
[ 2013-09-06 07:48:35.6479 32582/7f4d0711b700 Pool2/Implementation.cpp:1172 ]: [App 32622 stderr]   from /usr/lib/ruby/gems/1.8/gems/passenger-4.0.14/lib/phusion_passenger/ruby_core_enhancements.rb:81:in `writev2'
[ 2013-09-06 07:48:35.6479 32582/7f4d0711b700 Pool2/Implementation.cpp:1172 ]: [App 32622 stderr]   from /usr/lib/ruby/gems/1.8/gems/passenger-4.0.14/lib/phusion_passenger/utils/unseekable_socket.rb:126:in `writev2'
[ 2013-09-06 07:48:35.6479 32582/7f4d0711b700 Pool2/Implementation.cpp:1172 ]: [App 32622 stderr]   from /usr/lib/ruby/gems/1.8/gems/passenger-4.0.14/lib/phusion_passenger/rack/thread_handler_extension.rb:130:in `process_request'
[ 2013-09-06 07:48:35.6480 32582/7f4d0711b700 Pool2/Implementation.cpp:1172 ]: [App 32622 stderr]   from /usr/lib/ruby/gems/1.8/gems/passenger-4.0.14/lib/phusion_passenger/request_handler/thread_handler.rb:140:in `accept_and_process_next_request'
[ 2013-09-06 07:48:35.6480 32582/7f4d0711b700 Pool2/Implementation.cpp:1172 ]: [App 32622 stderr]   from /usr/lib/ruby/gems/1.8/gems/passenger-4.0.14/lib/phusion_passenger/request_handler/thread_handler.rb:108:in `main_loop'
[ 2013-09-06 07:48:35.6480 32582/7f4d0711b700 Pool2/Implementation.cpp:1172 ]: [App 32622 stderr]   from /usr/lib/ruby/gems/1.8/gems/passenger-4.0.14/lib/phusion_passenger/request_handler.rb:441:in `block (3 levels) in start_threads'
[Fri Sep 06 07:48:35 2013] [error] [client 10.100.193.133] Premature end of script headers:

I received the following reply from Phusion on the phusion-passenger email list. 我从Phusion收到了以下有关回馈乘客电子邮件列表的回复。

> Exception TypeError in Passenger RequestHandler's client socket (wrong argument type Array (expected Struct)) (process 32622, thread 0x00000002c633e0(Worker 1)):

This error indicates that your Ruby interpreter is loading a native
extension that was compiled for a different Ruby version. Try cleaning
things up:

sudo rm -rf /usr/lib/ruby/gems/1.8/gems/passenger-4.0.14/buildout/ruby
rm -rf ~/.passenger/native_support

Then restart your web server and re-access your app. Does that help?

Since I had installed as sudo, I didn't have a ~/.passenger directory. 由于我已安装为sudo,所以没有〜/ .passenger目录。 But removing the buildout/ruby directory was enough to allow my 1.9.3 application to run. 但是删除buildout / ruby​​目录足以允许我的1.9.3应用程序运行。

I recently implemented Passenger 4.0.10 using different versions of Ruby (1.9.3 & 2.0.0). 我最近使用不同版本的Ruby(1.9.3和2.0.0)实现了Passenger 4.0.10。 Here are some things to check: 这里有一些要检查的东西:

Have you installed the Passenger gem in each RVM gemset? 您是否在每个RVM宝石集中都安装了Passenger宝石? When I was having problems with this I was advised to do this by the Passenger team. 当我对此有疑问时,乘客团队建议我这样做。

Did you check out the RVM Helper Tool for PassengerRuby in the documentation? 您是否在文档中签出了用于PassengerRuby的RVM帮助器工具 Here is the link for the PassengerRoot Documentation from Passenger. 这是来自Passenger的PassengerRoot文档的链接。 You probably have the wrong value for PassengerRuby. 您可能对PassengerRuby的值有误。 You will need to execute the which passenger-config command in each gemset to get the correct command to execute for passenger config. 您将需要在每个gemset中执行which passenger-config命令,以获取要为乘客配置执行的正确命令。 There are two sections in the output of passenger-config --ruby-command which mentions values for PassengerRuby. passenger-config --ruby-command输出中有两节提到了PassengerRuby的值。 I used the value mentioned in the first section in the output in my virtual host config file. 我在虚拟主机配置文件的输出中使用了第一部分中提到的值。

Note: Sometimes RVM for me can be a nightmare :) I had to look at the RVM Helper Tool documentation several times (and several failed attempts) before getting this to work. 注意:有时,对我来说RVM可能是一场噩梦:)在使此功能生效之前,我不得不查看RVM Helper Tool文档几次(以及几次失败的尝试)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM