Apache-Passenger 无法启动我的生产 rails 应用程序

Apache-Passenger can't start my production rails application

我是部署 rails 应用程序的新手,对于我在许多网站上阅读的内容,Apache/Passenger 组合是最简单的组合之一;但是我遇到过 Passenger 不想启动我的应用程序并在输入 sudo tail -50 /var/log/apache2/error.log 时显示以下错误消息 命令:

Could not spawn process for application /home/test/Documents/sites/depot:
An error occured while starting up the preloader.
Message from application: cannot load such file -- bundler/setup (LoadError)
/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require'
/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:406:in
`activate_gem'
...
age/Cor/Req/CheckoutSession.cpp:252 ]: [Client 1-1] Cannot checkout session
because a spawning error occurred. The identifier of the error is 6ce15bbe.
Please see earlier logs for details about the error.

我怀疑这与我的 ruby 安装有关,我使用 rbenv 并获得了 2.2.3 版本,但在错误消息中它链接到我从未安装过的 2.0.0 版本。 我还怀疑它与我使用另一个指南中的这两个命令有关:

 sudo rm /usr/bin/ruby
 sudo ln -s /usr/local/bin/ruby /usr/bin/ruby

https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-passenger-and-apache-on-ubuntu-14-04

如果有人知道如何解决这个令人头疼的问题,我将不胜感激。

谢谢!

您可能需要在 httpd.conf 文件中指定正确的 PassengerDefaultRuby

我的建议是使用他们的官方指南完成 passenger 的安装:

https://www.phusionpassenger.com/library/install/apache/

根据@dimakura 和@CamdenNarzt 留下的一些线索,我分两个阶段解决了这个问题。

  1. 因为我怀疑 Passenger 使用了错误版本的 ruby,为了解决这个问题,我修改了位于 /etc/apache2/mods-available/ 下的 passenger.conf 文件,输出为 哪个ruby命令:

添加了行(替换为您自己的 ruby 输出)

PassengerRuby /home/test/.rbenv/shims/ruby
  1. 重新启动的 apache 收到一条 "Incomplete response received from application" 错误消息,检查日志并注意到现在正在使用 ruby 的正确版本,但收到一条错误消息:

    "Missing secret_token and secret_key_base for 'production' environment, set these values in config/secrets.yml"

按照此站点上的说明安装 Figaro gem:https://www.twilio.com/blog/2015/02/managing-development-environment-variables-across-multiple-ruby-applications.html 然后使用以下命令生成密钥:

rake secret

复制输出并打开我输入的 config/application.yml 文件:

SECRET_KEY_BASE: [output key from rake secret command]

重新启动 Apache,它成功了!