我在 CentOS 服务器上使用 Passenger 4.0.45 在 Apache 上运行多个网站。我也使用 rvm 1.25.27 安装了多个 ruby 版本,并且在过去 3 年中我使用 Ruby 2.1.2 版本。
我现在已经使用 Rails 5.1 启动了一个新应用程序,并且需要安装 Ruby 2.4.2。部署我的应用程序后,我得到一个 Internal Server Error
这是我在错误日志中收到的错误:
App 10033 stderr: /usr/local/rvm/gems/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e193948398ccd3cfd0cfd3a19380888d92ccd5cfd1" rel="noreferrer noopener nofollow">[email protected]</a>/gems/passenger-4.0.45/lib/phusion_passenger/request_handler.rb:356:in `trap'
App 10033 stderr: :
App 10033 stderr: Invalid argument - SIGKILL
App 10033 stderr: (
App 10033 stderr: Errno::EINVAL
App 10033 stderr: )
我注意到显示的 ruby 版本是 <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d2a0a7b0abffe0fce3fce092a0b3bbbea1ffe6fce2" rel="noreferrer noopener nofollow">[email protected]</a>
我认为应该是2.4.2
因为这是我在 VirtualHost 文件上指定的版本:
<VirtualHost *:80>
ServerName example.com
DocumentRoot /.../current/public
PassengerRuby /home/user/.rvm/wrappers/ruby-2.4.2@global/ruby
<Directory
/home/user/.../current/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
我在 https://github.com/phusion/passenger/issues/1362 上读到过有关此错误的信息但我不知道是否可以更新 Passenger,而不会弄乱我使用旧版本 Ruby 运行的其他网站。
最佳答案
我找到了问题的答案。我将解释我做了什么:
- rvm install 2.4.2(安装 Ruby 版本 2.4.2)
- rvm 使用 2.4.2(使用 Ruby 2.4.2 版本)
- gem install guest(安装 Passenger gem)
- passenger-install-apache2-module(这将引导您完成 Apache Passenger 模块的安装。大约需要 3 分钟)
- 完成 Passenger 模块的安装过程后,我使用由安装摘要)
- rvmsudo Passenger-config validate-install(检查 Passenger 是否安装正确)
- sudo service httpd restart(重新启动 Apache)
执行上述命令后,我使用 Rails 5.1 的新应用程序以及在较低 Ruby/Rails 版本上运行的服务器中的所有其他站点都可以正常工作。
关于ruby-on-rails - 乘客使用错误的 ruby 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47931746/