Rails4 中 由于secret key 引发在production环境下没法运行

错误信息git

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

由于rails 4 出于安全考虑,须要在production 的状况下 ,生成一个key,经过 web_app/config/secrets.yml 读取。web

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

因为安全方面的考虑,此key值不建议放入git发布。shell

解决方法安全

1.在服务器上 rake secret RAILS_ENV=production 生成key服务器

[root@iZ25ka6ra32Z weixin_post]# rake secret RAILS_ENV=production
77cc6867b69965249198ded31d6c346d97c1abf029c

2.在shell中 export 到环境变量中app

[root@iZ25ka6ra32Z weixin_post]# export SECRET_KEY_BASE=77cc6867b69965249198ded31d6c346d97
相关文章
相关标签/搜索