缺少`secret_token`和`secret_key_base`用于'生产'登录redmine

时间:2016-11-17 08:46:05

标签: ruby centos

我在CentOS 7.2上安装redmine,Rails 4.2,ruby 2.1.2p95(2014-05-08修订版45877)[x86_64-linux-gnu]。当我使用命令启动服务器时:

ruby /usr/local/bin/rails server webrick -e production –d

登录:http://localhost:3000。抛出:

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

enter image description here 这是我的秘密。名字:

development:
  secret_key_base: 58176e0eea05......

test:
  secret_key_base: 58176e0eea05......

# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
  secret_key_base: 58176e0eea05......

我已经尝试生成一个密钥,我该怎么做才能使它正确?

这是详细日志:

[root@localhost redmine]# ruby /usr/local/bin/rails server webrick -e production –d
=> Booting WEBrick
=> Rails 4.2.7.1 application starting in production on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2016-11-17 04:09:06] INFO  WEBrick 1.3.1
[2016-11-17 04:09:06] INFO  ruby 2.0.0 (2014-11-13) [x86_64-linux]
[2016-11-17 04:09:06] INFO  WEBrick::HTTPServer#start: pid=2972 port=3000
http://localhost:3000[2016-11-17 04:09:25] ERROR RuntimeError: Missing `secret_token` and `secret_key_base` for 'production' environment, set these values in `config/secrets.yml`
        /usr/local/share/gems/gems/railties-4.2.7.1/lib/rails/application.rb:534:in `validate_secret_key_config!'
        /usr/local/share/gems/gems/railties-4.2.7.1/lib/rails/application.rb:246:in `env_config'
        /usr/local/share/gems/gems/railties-4.2.7.1/lib/rails/engine.rb:514:in `call'
        /usr/local/share/gems/gems/railties-4.2.7.1/lib/rails/application.rb:165:in `call'
        /usr/local/share/gems/gems/rack-1.6.5/lib/rack/lock.rb:17:in `call'
        /usr/local/share/gems/gems/rack-1.6.5/lib/rack/content_length.rb:15:in `call'
        /usr/local/share/gems/gems/rack-1.6.5/lib/rack/handler/webrick.rb:88:in `service'
        /usr/share/ruby/webrick/httpserver.rb:138:in `service'
        /usr/share/ruby/webrick/httpserver.rb:94:in `run'
        /usr/share/ruby/webrick/server.rb:295:in `block in start_thread'

1 个答案:

答案 0 :(得分:1)

生成密钥:

    #change to redmine directory
    cd /var/www/redmine

    #generate secret key
    rake secret RAILS_ENV=production

    export SECRET_KEY_BASE=generate key

    #check secret key
    echo $SECRET_KEY_BASE

重新启动。