Capistrano部署到EC2,用户权限

sep*_*err 1 capistrano amazon-ec2

我有一个rails应用程序,我试图使用Capistrano部署到ec2实例.我的deploy.rb:

set :application, "uc_social_server"
set :repository,  "septerr@bitbucket.org/urbancoding/uc_social_server.git"
set :user, "ec2-user"
server "ec2-23-22-188-11.compute-1.amazonaws.com", :app, :web, :db, :primary => true
set :deploy_to, "/home/ec2-user/uc_social_server"
ssh_options[:keys] = %w(/Users/sony/.ssh/ec2-social-server-key.pem)
default_run_options[:pty] = true
Run Code Online (Sandbox Code Playgroud)

运行cap deploy:check失败:

The following dependencies failed. Please check them and try again:
--> You do not have permissions to write to `/home/ec2-user/uc_social_server/releases'. (ec2-23-22-188-11.compute-1.amazonaws.com)
Run Code Online (Sandbox Code Playgroud)

我已经尝试了一些我在stackoverflow上找到的解决方案但没有成功.使用capistrano部署到ec2的正确方法是什么?

sep*_*err 5

终于找到了问题所在.

cap deploy:setup 默认情况下,root将成为其创建的文件夹的所有者.

因此,在运行之前,cap deploy:setup必须记住添加set :use_sudo, false到deploy.rb(或您正在使用的capistrano脚本文件).

如果你像我一样已经运行设置命令导致releasesshared文件夹与根的所有权,

  1. ssh到你的ec2机器并删除这些文件夹
  2. 添加 set :use_sudo, false到您的capistrano脚本(在我的情况下为deploy.rb)
  3. cap deploy:setup

现在,capistrano应该使用您在capistrano脚本中指定的用户创建releasesshared文件夹作为所有者.

cap deploy:check 现在应该成功.