【问题标题】:How to enable production mode in ruby on rails?如何在 ruby​​ on rails 中启用生产模式?
【发布时间】:2016-04-21 07:11:03
【问题描述】:

您好,我想知道我需要做什么才能在 RoR 中启用生产模式。

当我将 RailsEnv 生产线添加到我的 Apache 时,重新启动后我收到一条错误消息“我们很抱歉,但出了点问题。apache ruby​​”。

日志是空的,我在生产模式下迁移了数据库,编译了资产,设置 RAILS_ENV 安装所有,但我不能在生产中运行,在开发中工作正常。

我使用 Apache2 + Passenger。你会帮我吗?

提前谢谢你!

【问题讨论】:

  • 查看您的 log/production.log 文件以了解确切的错误。
  • @Uzbekjon 日志/production.log 包含以下内容:D,[2016-04-20T13:47:17.810796 #17104] DEBUG -- : ActiveRecord::SchemaMigration Load (0.7ms) SELECT @987654322 @.* FROM schema_migrations D, [2016-04-20T13:47:26.763094 #17140] 调试 -- : ActiveRecord::SchemaMigration Load (0.1ms) SELECT schema_migrations.* FROM schema_migrations D, [2016- 04-20T13:59:40.486879 #4955] DEBUG -- : ActiveRecord::SchemaMigration Load (0.7ms) SELECT schema_migrations.* FROM schema_migrations
  • 您是否在生产环境中创建并迁移了您的数据库 (rake db:setup RAILS_ENV=production)?

标签: ruby-on-rails ruby apache passenger


【解决方案1】:

假设您在 config/database.yml

中正确定义了生产数据库信息

您可以通过像这样启动应用程序以生产模式启动 Rails:

$ rails s -e production -p 80 --bind=0.0.0.0

更多关于 Rails 环境设置的信息可以在这里找到:http://guides.rubyonrails.org/configuring.html

【讨论】:

  • 谢谢@Hugo,我运行了评论但没有用。我配置了 database.yml 并且可以正确迁移。出现这个错误:/home/myusername/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.2.4/lib/action_controller/metal/request_forgery_protection.rb:114:in`在 protection_method_class' 中救援:请求伪造保护方法无效,使用 :null_session、:exception 或 :reset_session (ArgumentError)
  • 也许这可以帮助你:stackoverflow.com/questions/6918879/…
猜你喜欢
  • 1970-01-01
  • 2013-05-25
  • 1970-01-01
  • 2011-07-07
  • 1970-01-01
  • 1970-01-01
  • 2022-08-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多