【发布时间】:2014-11-02 16:12:20
【问题描述】:
我正在尝试将我的 Rails 应用程序部署到我的 Digital Ocean VPS。我已经完成了GoRails guide 中的所有步骤,但是当我部署我的项目并访问我的 IP 地址时,我收到一条消息:
An error occurred.
Sorry, the page you are looking for is currently unavailable.
Please try again later.
If you are the system administrator of this resource then you should check the error log for details.
Faithfully yours, nginx.
我检查了显示我的 nginx 错误日志:
Exception RuntimeError in Rack application object (Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml`) (process 2490, thread 0x007fbd33665ce0(Worker 1)):
在 VPS 上,我通过运行 rake secret 然后运行 export SECRET_KEY_BASE= + key 创建了一个秘密。现在当我echo $SECRET_KEY_BASE 时,它会显示我的钥匙。但我仍然收到错误消息。
在我的deploy.rb 我有这个:
set :linked_files, %w{config/database.yml config/secrets.yml}
我在 VPS 上的secrets.yml 是这样的:
development:
secret_key_base: 89dacb16fd905ff4c6352ac93f4676a5dd&^%3f93edce9a5be796712d54b57b91e1335598fd73e3998fddbbdeaf3ee7f65157f2fb01ce1bea5658aa7bf745d1f
test:
secret_key_base: cf351585b2cb43459f5a073cbfd885b3dd2af44124f13a855522f678c1cf06625c121cd3b7857&&6e7fe2ba11180066753142143231c79c513e71e20372a0462
# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
刚刚重启了nginx,还是没有结果。
更新
deploy@movieseat:~$ ps aux | grep nginx
root 4545 0.0 0.6 98936 3360 ? Ss 11:32 0:00 nginx: master process /usr/sbin/nginx
www-data 4548 0.0 0.9 99304 4608 ? S 11:32 0:00 nginx: worker process
www-data 4549 0.0 0.9 99304 4608 ? S 11:32 0:00 nginx: worker process
www-data 4550 0.0 0.9 99304 4608 ? S 11:32 0:00 nginx: worker process
www-data 4551 0.0 0.9 99304 4608 ? S 11:32 0:00 nginx: worker process
deploy 4655 0.0 0.3 9436 1660 pts/1 S+ 11:33 0:00 grep --color=auto nginx
【问题讨论】:
-
确保
SECRET_KEY_BASE设置为与 nginx 和乘客运行相同的用户。 -
我该如何检查?我使用
ssh deploy@***.**.***.**登录,然后运行所有命令。我还以该用户身份重新启动了 nginx。所以我认为 nginx 和乘客从部署用户运行。 -
它没有显示任何输出。
deploy@movieseat:~$ ls -la | grep nginx deploy@movieseat:~$ -
对不起,我在睡觉,我的意思是:
ps aux | grep nginx -
@PeterBoomsma :试试这个:1:运行:
RAILS_ENV=production rake secret,2:打开你的 bashrc:vi ~/.bashrc,把它放进去:export SECRET_KEY_BASE = value_you_get_from_rake_secret_command_without_quote例如:export SECRET_KEY_BASE=abjdbjd28hewu83tg,3:运行:source ~/.bashrc或者重新登录服务器,4:重启rails服务器。
标签: ruby-on-rails ruby nginx