Rails:将“master.key"移动到生产服务器 [英] Rails: Moving `master.key` to production server
问题描述
我正在尝试使用 mina
当我运行 mina deploy
时,我收到错误 缺少用于解密文件的加密密钥.向您的团队询问您的主密钥并将其写入/home/my_rails_project/app/tmp/build-153920174210305/config/master.key 或将其放入 ENV['RAILS_MASTER_KEY']
.
When I run mina deploy
I get the error Missing encryption key to decrypt file with. Ask your team for your master key and write it to /home/my_rails_project/app/tmp/build-153920174210305/config/master.key or put it in the ENV['RAILS_MASTER_KEY']
.
我期待这个错误,因为我还没有想出如何将详细信息添加到服务器.
I was expecting this error as I haven't yet worked out how to add the details to the server.
许多文章表明有两种方法可以做到这个:
A number of articles suggest there are two means of doing this:
选项 1:将 config/master.key
文件放在服务器中.您通常希望将此文件符号链接到服务器中的共享文件夹文件系统.同样,不要对 config/master.key
文件进行版本控制.
Option 1: Place the
config/master.key
file in the server. You’ll normally want to symlink this file to a shared folder in the server filesystem. Again, do not version yourconfig/master.key
file.
选项 2:创建一个 RAILS_MASTER_KEY ENV
变量.Rails 会检测到它并将其用作您的主密钥,例如在heroku中:heroku config:setRAILS_MASTER_KEY= <你的主密钥在这里 >
.
Option 2: create a RAILS_MASTER_KEY ENV
variable. Rails will detect it and use it as your master key, e.g. in heroku: heroku config:set
RAILS_MASTER_KEY= < your-master-key-here >
.
我已尝试使用 FileZilla 的选项 1,但是,我无法访问文章建议文件应存储在的文件夹 /home/deploy/my-rails-project/shared/config/master.key
-> 错误:目录/home/my-rails-project/app/shared/config:权限被拒绝
.我也无法通过 FileZilla 在本地计算机上看到 master.key
文件.同样,如果我在 Digital Ocean 上使用控制台,我会收到 permission denied
错误
I have tried option 1 using FileZilla, however, I am unable to access the folder which is where the article suggests the file should be stored /home/deploy/my-rails-project/shared/config/master.key
-> Error: Directory /home/my-rails-project/app/shared/config: permission denied
. I am also unable to see the master.key
file on my local computer through FileZilla. Similarly, if I use the console on Digital Ocean I get the permission denied
error
请您告诉我如何将 master.key
移动到生产服务器
Please could you advise me how to move master.key
to the production server
预先感谢您的帮助
推荐答案
按照@edudepetris 的建议,我最终确定了如何执行选项 2.这包括将 RAILS_MASTER_KEY=<my_master.key>
行添加到我的 .bashrc
的顶部 - 这是通过键入 nano .bashrc
完成的登录服务器时
I ended up working out how to do option 2, as suggested by @edudepetris. This involved adding the line RAILS_MASTER_KEY=<my_master.key>
to the top of my .bashrc
- this was done by typing nano .bashrc
when logged into the server
这篇关于Rails:将“master.key"移动到生产服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!