SemiFixed:缺少'secret_key_base`用于'制作'环境 [英] SemiFixed: Missing `secret_key_base` for 'production' environment

查看:166
本文介绍了SemiFixed:缺少'secret_key_base`用于'制作'环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从头创建了一个Rails应用程序(Rails 4.1.0),并且遇到了一个我无法解决的问题。我已经安装并配置了Apache Passenger Module,它工作正常。任何时候我尝试访问虚拟主机时,都会收到错误500:

 缺少'生产'环境的secret_key_base,请设置此值在config / secrets.yml中

secret.yml文件包含以下配置:

  secret_key_base:<%= ENV [SECRET_KEY_BASE]%> 

即使不推荐我这样做:

 制作:
secret_key_base:XXXXXXXXXXXXXXXXXXXXXXXXXXXX(随机密钥)

但是Apache日志显示了这一点:

 #tailf / etc / httpd / logs / error_log 
[Tue May 06 12:56:18 2014] [错误] [client 192.168.3.1]脚本标题过早结束:
App 4405 stderr:[2014-05-06 12:56:18.5763 4421 / 0x9d48bdc(Worker 1) utils.rb:68]:***在Rack应用程序对象中缺少RuntimeError(在'生产'环境中缺少`secret_key_base`,将此值设置为`config / secrets.yml`)(进程4421,线程0x9d48bdc(Worker 1)) :
App 4405 stderr:from /usr/local/rvm/gems/ruby-2.1.1/gems/railties-4.1.0/lib/rails/application.rb:440:in`validate_secret_key_config!'
App 4405 stderr:from /usr/local/rvm/gems/ruby-2.1.1/gems/railties-4.1.0/lib/rails/application.rb:195:in`env_config'
App 4405标准错误: from /usr/local/rvm/gems/ruby-2.1.1/gems/railties-4.1.0/lib/rails/engine.rb:510:in`call'
App 4405 stderr:from / usr / local / rvm / gems / ruby​​-2.1.1 / gems / railties-4.1.0 / lib / rails / application.rb:144:在`call'
App 4405 stderr:from / usr / local / rvm / gems / ruby​​-2.1.1 / gems / passenger-4.0.41 / lib / phusion_passenger / rack / thread_handler_extension.rb:74:in`process_request'
App 4405 stderr:from / usr / local / rvm / gems / ruby-2.1.1 / gems / passenger-4.0.41 / lib / phusion_passenger / request_handler / thread_handler.rb:141:in`accept_and_process_next_request'
App 4405 stderr:from / usr / local / rvm / gems / 2.1.1 / gems / passenger-4.0.41 / lib / phusion_passenger / request_handler / thread_handler.rb:109:在`main_loop'中
应用4405 stderr:从/usr/local/rvm/gems/ruby-2.1。 1 / gems / passenger-4.0.41 / lib / phusion_passenger / request_handler.rb:448:在start_threads中的块(3级)'

我如何解决这个错误?我如何访问开发环境?我的意思是我如何编写代码,在浏览器中测试,然后部署到Heroku或者只是在生产环境中测试?
$ b 更新



我通过在VirtualHost上设置 RailsEnv开发来解决上述错误,但是现在我得到了另一个错误:


SQLite3 :: CantOpenException无法打开数据库文件
Rails.root:/ var / www / html / moviedb


我正在尝试使用此创业板进行查询到TheMovieDB网站并获得结果。关于这个新错误的建议?

解决方案

我在生产服务器上创建了一个配置文件(confthin.yml )for Thin(我正在使用它)并添加以下信息:

environment:production
user:www-data
group:www -data
SECRET_KEY_BASE:mysecretkeyproduction



然后,我会以

启动应用程序 - whereeveristhefieonprod / configthin.yml



像魅力一样工作,不需要在版本控制上拥有密钥



希望它可以帮助,但我确信同样的事情可以用Unicorn和其他人完成。


I've created a rails app (Rails 4.1.0) from scratch and I am getting a problem that I am not able to solve. I have installed and configured Apache Passenger Module, it works fine. Any time I try to access the virtual host I get an error 500:

Missing secret_key_base for 'production' environment, set this value in config/secrets.yml

The secret.yml file contains the following configuration:

secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

Even when it's not recommended I did this:

    production:
  secret_key_base: XXXXXXXXXXXXXXXXXXXXXXXXXXXX (random key)

But Apache logs show this:

# tailf /etc/httpd/logs/error_log
[Tue May 06 12:56:18 2014] [error] [client 192.168.3.1] Premature end of script headers:
App 4405 stderr: [ 2014-05-06 12:56:18.5763 4421/0x9d48bdc(Worker 1) utils.rb:68 ]: *** Exception RuntimeError in Rack application object (Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml`) (process 4421, thread 0x9d48bdc(Worker 1)):
App 4405 stderr:        from /usr/local/rvm/gems/ruby-2.1.1/gems/railties-4.1.0/lib/rails/application.rb:440:in `validate_secret_key_config!'
App 4405 stderr:        from /usr/local/rvm/gems/ruby-2.1.1/gems/railties-4.1.0/lib/rails/application.rb:195:in `env_config'
App 4405 stderr:        from /usr/local/rvm/gems/ruby-2.1.1/gems/railties-4.1.0/lib/rails/engine.rb:510:in `call'
App 4405 stderr:        from /usr/local/rvm/gems/ruby-2.1.1/gems/railties-4.1.0/lib/rails/application.rb:144:in `call'
App 4405 stderr:        from /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.41/lib/phusion_passenger/rack/thread_handler_extension.rb:74:in `process_request'
App 4405 stderr:        from /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.41/lib/phusion_passenger/request_handler/thread_handler.rb:141:in `accept_and_process_next_request'
App 4405 stderr:        from /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.41/lib/phusion_passenger/request_handler/thread_handler.rb:109:in `main_loop'
App 4405 stderr:        from /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.41/lib/phusion_passenger/request_handler.rb:448:in `block (3 levels) in start_threads'

How I can fix this error? How do I access the development enviroment? I mean how I can write code, test in my browser and then deploy to Heroku or just test in production enviroment?

Update

I manage to fix the error above by setting RailsEnv development on VirtualHost but now I get this other error:

SQLite3::CantOpenException unable to open database file Rails.root: /var/www/html/moviedb

I'm trying to use this GEM for make queries to TheMovieDB website and get results. Any advice on this new error?

解决方案

What I did : On my production server, I create a config file (confthin.yml) for Thin (I'm using it) and add the following information :

environment: production user: www-data group: www-data SECRET_KEY_BASE: mysecretkeyproduction

I then launch the app with

thin start -C /whereeveristhefieonprod/configthin.yml

Work like a charm and then no need to have the secret key on version control

Hope it could help, but I'm sure the same thing could be done with Unicorn and others.

这篇关于SemiFixed:缺少'secret_key_base`用于'制作'环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆