【问题标题】:Rails in production with Apache+passenger errorRails 在生产中出现 Apache+passenger 错误
【发布时间】:2015-10-30 17:41:33
【问题描述】:

最近几天,我正在尝试使用 apache 和乘客(无 rvm)将我的 rails 应用程序投入生产,但仍然没有。在我的浏览器中,我收到这样的错误:

We're sorry, but something went wrong.
We've been notified about this issue and we'll take a look at it shortly.

当在我的终端中给 tail /var/log/apache2/error.log 我得到这个:

 /home/gre_stag/.rbenv/versions/2.2.2/lib/ruby/2.2.0/irb/ruby-lex.rb:230:in `catch'
  /home/gre_stag/.rbenv/versions/2.2.2/lib/ruby/2.2.0/irb/ruby-lex.rb:230:in `each_top_level_statement'
  /home/gre_stag/.rbenv/versions/2.2.2/lib/ruby/2.2.0/irb.rb:485:in `eval_input'
  /home/gre_stag/.rbenv/versions/2.2.2/lib/ruby/2.2.0/irb.rb:395:in `block in start'
  /home/gre_stag/.rbenv/versions/2.2.2/lib/ruby/2.2.0/irb.rb:394:in `catch'
  /home/gre_stag/.rbenv/versions/2.2.2/lib/ruby/2.2.0/irb.rb:394:in `start'
  /home/gre_stag/.rbenv/versions/2.2.2/bin/irb:11:in `<main>'


[ 2015-08-07 12:33:23.9794 4936/7f1db502e700 age/Cor/Req/CheckoutSession.cpp:252 ]: [Client 1-1] Cannot checkout session because a spawning error occurred. The identifier of the error is cfaf3a49. Please see earlier logs for details about the error.

在 /etc/apache2/sites-available/depot.conf 我有这个代码:

<VirtualHost *:80>
    PassengerRuby /home/gre_stag/.rbenv/versions/2.2.2/bin/irb
    ServerName depot.local
    ServerAlias www.depot.local
    ServerAdmin webmaster@localhost
    PassengerRoot /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini
    DocumentRoot /home/gre_stag/RoR/workspace/depot/public
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    <Directory /home/gre_stag/RoR/workspace/depot/public>
        Options FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

我不确定“PassengerRuby”的价值。 这是我第一次使用 apache。我将不胜感激。

更新

/var/log/apache2/error.log

home/gre_stag/RoR/workspace/Agile_web_dev/depot: An error occured while starting up the preloader.
  Error ID: 78043345
  Error details saved to: /tmp/passenger-error-zWC057.html
  Message from application: YAML syntax error occurred while parsing /home/gre_stag/RoR/workspace/Agile_web_dev/depot/config/database.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Error: (<unknown>): mapping values are not allowed in this context at line 25 column 11 (RuntimeError)
  /home/gre_stag/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/application/configuration.rb:115:in `rescue in database_configuration'
  /home/gre_stag/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/application/configuration.rb:98:in `database_configuration'
  /home/gre_stag/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activerecord-4.2.1/lib/active_record/railtie.rb:117:in `block (2 levels) in <class:Railtie>'
  /home/gre_stag/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
  /home/gre_stag/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
  /home/gre_stag/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
  /home/gre_stag/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/lazy_load_hooks.rb:44:in `each'
  /home/gre_stag/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'

gemi 文件:

source 'https://rubygems.org'

gem 'rails', '4.2.1'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  gem 'byebug'
  gem 'web-console', '~> 2.0'
  gem 'spring'
  gem 'sqlite3'

group :test do
  gem 'minitest-reporters', '1.0.5'
  gem 'mini_backtrace',     '0.1.3'
  gem 'guard-minitest',     '2.3.1'
end
group :production do
  gem 'mysql2'
end
end

【问题讨论】:

    标签: ruby-on-rails apache


    【解决方案1】:

    你应该使用 ruby​​ 二进制而不是 irb。

    PassengerRuby /home/gre_stag/.rbenv/versions/2.2.2/bin/irb 更改为PassengerRuby /home/gre_stag/.rbenv/versions/2.2.2/bin/ruby

    【讨论】:

    • 感谢您的回答,我做到了,但它不起作用。只有tail /var/log/apache2/error.log 有变化:config.ru:1:in new' config.ru:1:in &lt;main&gt;' /usr/share/passenger/helper-scripts/rack-preloader.rb:107:in eval' /usr/share/passenger/helper-scripts/rack-preloader.rb:107:in preload_app' /usr/share/passenger/helper-scripts/rack-preloader.rb:153:in ' /usr/share/passenger/helper-scripts/rack-preloader.rb:29:in &lt;module:PhusionPassenger&gt;' /usr/share/passenger/helper-scripts/rack-preloader.rb:28:in
      '`
    • 通过调用'bundle'检查你使用的gem是否全部安装。此外,如果您可以从 apache 日志文件中显示更多行,它会更有帮助
    • 我用 gemfile 和 apache 日志文件错误更新了我的帖子。
    • 我在 .yaml 文件中有一个错误。我修好了,现在我得到了Incomplete response received from application
    • 我想你错过了生成 secret_missing_key stackoverflow.com/questions/29241053/…
    【解决方案2】:

    问题是“生产”环境缺少“secret_key_base”,我按照来自here 的 Demi Magus 的指导解决了它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-04
      • 2011-12-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-08
      • 1970-01-01
      相关资源
      最近更新 更多