之前有人回答说你需要直接在bashrc文件中设置变量。我使用的是Ubuntu VPS,我遵循了本教程:https://www.digitalocean.com/community/tutorials/how-to-install-rails-and-nginx-with-passenger-on-ubuntu
告诉nginx日志文件,我得到了这个输出:
App 2435 stderr: [ 2014-11-12 22:24:39.9703 2451/0x0000000109d610(Worker 1) utils.rb:84 ]: *** Exception RuntimeError in Rack application object (Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml`) (process 2451, thread 0x0000000109d610(Worker 1)):
App 2435 stderr: from /home/XXXXX/.rvm/gems/ruby-2.1.4/gems/railties-4.1.7/lib/rails/application.rb:462:in `validate_secret_key_config!'
App 2435 stderr: from /home/XXXXX/.rvm/gems/ruby-2.1.4/gems/railties-4.1.7/lib/rails/application.rb:195:in `env_config'
App 2435 stderr: from /home/XXXXX/.rvm/gems/ruby-2.1.4/gems/railties-4.1.7/lib/rails/engine.rb:510:in `call'
App 2435 stderr: from /home/XXXXX/.rvm/gems/ruby-2.1.4/gems/railties-4.1.7/lib/rails/application.rb:144:in `call'
App 2435 stderr: from /home/XXXXX/.rvm/gems/ruby-2.1.4/gems/passenger-4.0.53/lib/phusion_passenger/rack/thread_handler_extension.rb:74:in `process_request'
App 2435 stderr: from /home/XXXXX/.rvm/gems/ruby-2.1.4/gems/passenger-4.0.53/lib/phusion_passenger/request_handler/thread_handler.rb:141:in `accept_and_process_next_request'
App 2435 stderr: from /home/XXXXX/.rvm/gems/ruby-2.1.4/gems/passenger-4.0.53/lib/phusion_passenger/request_handler/thread_handler.rb:109:in `main_loop'
App 2435 stderr: from /home/XXXXX/.rvm/gems/ruby-2.1.4/gems/passenger-4.0.53/lib/phusion_passenger/request_handler.rb:455:in `block (3 levels) in start_threads'
每次加载网页时都会发生此错误。该页面是502 Bad Gateway。我的nginx配置文件:
user XXXXX;
worker_processes 2;
worker_priority -5;
error_log /home/rails/log/nginx.error.log crit;
events {
use epoll;
worker_connections 1024;
}
http {
passenger_root /home/XXXXX/.rvm/gems/ruby-2.1.4/gems/passenger-4.0.53;
passenger_ruby /home/XXXXX/.rvm/gems/ruby-2.1.4/wrappers/ruby;
server { listen 80; server_name rails.pt localhost; passenger_enabled on; root /home/rails/public; }
}
XXXXX是服务器名称,但我实际上使用的是server_name rails.pt localhost;因为我不确定还能去那里。
表演 echo $ SECRET_KEY_BASE会回显我生成的密钥。
有关如何使这项工作的任何建议?我试过停止并启动nginx,我甚至重新启动了整个Droplet几次。我试图运行的应用程序是完全空白的,是在Droplet上制作的。