繁体   English   中英

使用Capistrano在AWS EC2上部署Rails应用

[英]Deploying Rails App on AWS EC2 with Capistrano

我正在尝试使用Capistrano在默认用户(Ubuntu)部署在AWS-EC2实例上的另一个用户家中的Rails应用程序,但这给了我一个“权限被拒绝”错误。 这是我的代码:

server "9.9.9.9", :web, :app, :db, primary: true

set :application, "some_app"
set :user, "ubuntu"
set :keep_releases, 3
set :location, "9.9.9.9"
ssh_options[:keys] = ["~/Keys/serverkey.pem"]
ssh_options[:forward_agent] = true
default_run_options[:pty] = true
set :use_sudo, false

task :hello do
  run "echo 'Hello World' > /home/other_user/i_was_here.txt"
end

这是输出:

$ cap hello
  * 2013-03-22 14:11:29 executing `hello'
  * executing "echo 'Hello World' > /home/other_user/i_was_here.txt"
    servers: ["9.9.9.9"]
    [9.9.9.9] executing command
 ** [out :: 9.9.9.9] sh: cannot create /home/other_user/i_was_here.txt: Permission denied
    command finished in 798ms
failed: "sh -c 'echo '\\''Hello World'\\'' > /home/other_user/i_was_here.txt'" on 9.9.9.9

有什么事吗 目的是为另一个用户部署Rails应用程序,因此我有些怀疑:

  1. 有没有一种方法可以与其他用户直接在AWS-EC2实例上部署Rails App?
  2. 如果#1的答案为“否”,那么使用默认用户Ubuntu为其他用户部署Rails App的正确方法是什么? (因为以后其他用户尝试访问应用程序时,权限不会出现问题)

在服务器中管理着许多用户,因为我们想获取每个用户的存储和带宽,所以我们是这样做的,直到今天我们还是从Capistrano haha​​开​​始。

提前致谢。

通常是以应运行/维护应用程序的用户身份进行部署。 否则,您必须真正确保两个用户都不会弄乱权限。

这种情况的原因是您不想共享凭据吗? 如果是这样,请考虑使用为每个用户添加到.ssh/authorized_keys的特殊deploy ssh密钥。

从您的配置文件中删除ssh_options[:forward_agent] = true行,即使我遇到了同样的问题,我也删除了该行,并且现在对我来说还可以

谢谢大家的回答。 我要做的就是遵循以下步骤,并与特定用户与Capistrano建立联系。

http://utkarshsengar.com/2011/01/manage-multiple-accounts-on-1-amazon-ec2-instance/

除非使用sudo,否则ubuntu用户无权访问other_user的主目录,或者您更改了/ home / other_user的权限。

如果要以other_user身份运行应用程序,最好的方法是将capistrano配置为以other_user身份进行部署。 您需要将公共ssh密钥添加到/home/other_user/.ssh/authorized_keys。 如果要使该应用程序以ubuntu身份运行,请部署到/ home / ubuntu。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM