微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ruby-on-rails – capistrano git部署:无法创建工作树目录:权限被拒绝

我正在使用git和capistrano与乘客一起部署.我一直在试图做这项工作几个小时,并没有取得多大进展. cap deploy:安装程序正常,但是cap部署失败并出现权限问题.我尝试在我的切片上更改权限/所有权,但它仍然失败.

require 'bundler/capistrano'
set :user,'some_user'
set :domain,'example.com'
set :applicationdir,"/home/some_user/public_html/example"
set :port,30000

set :scm,'git'
set :repository,"ssh://git@123.45.678.910:50000/home/git/example"
set :branch,'master'
set :scm_verbose,true

# roles (servers)
role :web,domain
role :app,domain
role :db,domain,:primary => true

# deploy config
set :deploy_to,applicationdir
set :deploy_via,:remote_cache

# additional settings
default_run_options[:pty] = true  
ssh_options[:forward_agent] = true

# Passenger
namespace :deploy do
  task :start do ; end
  task :stop do ; end
  task :restart,:roles => :app,:except => { :no_release => true } do
    run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
  end
end

导致以下错误

executing `deploy'
  * executing `deploy:update'
 ** transaction: start
  * executing `deploy:update_code'
    updating the cached checkout on all servers
    executing locally: "git ls-remote ssh://git@123.45.678.910:50000/home/git/example.com master"
/Users/some_user/.rvm/gems/ruby-1.9.2-p0/gems/capistrano-2.6.0/lib/capistrano/recipes/deploy.rb:104: warning: Insecure world writable dir /usr/local/bin in PATH,mode 040777
    command finished in 78068ms
  * executing "if [ -d /home/some_user/public_html/example.com/shared/cached-copy ]; then cd /home/some_user/public_html/example.com/shared/cached-copy && git fetch  origin && git fetch --tags  origin && git reset  --hard c7f73668d0656c665a6445c33870d05a8550ab2c && git clean  -d -x -f; else git clone   ssh://git@123.45.678.910:50000/home/git/example.com /home/some_user/public_html/example.com/shared/cached-copy && cd /home/some_user/public_html/example.com/shared/cached-copy && git checkout  -b deploy c7f73668d0656c665a6445c33870d05a8550ab2c; fi"
    servers: ["example.com"]
    [example.com] executing command
 ** [example.com :: out] fatal: Could not create work tree dir '/home/some_user/public_html/example.com/shared/cached-copy'.: Permission denied
    command finished in 353ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /home/some_user/public_html/example.com/releases/20110610173027; true"
    servers: ["example.com"]
    [example.com] executing command
    command finished in 218ms
Failed: "sh -c 'if [ -d /home/some_user/public_html/example.com/shared/cached-copy ]; then cd /home/some_user/public_html/example.com/shared/cached-copy && git fetch  origin && git fetch --tags  origin && git reset  --hard c7f73668d0656c665a6445c33870d05a8550ab2c && git clean  -d -x -f; else git clone   ssh://git@123.45.678.910:50000/home/git/example.com /home/some_user/public_html/example.com/shared/cached-copy && cd /home/some_user/public_html/example.com/shared/cached-copy && git checkout  -b deploy c7f73668d0656c665a6445c33870d05a8550ab2c; fi'" on example.com

解决方法

不确定这会有多大帮助,但在部署:setup之后我总是遇到权限问题

运行deploy:setup时,它会为您创建初始目录.但是它创建的那些文件夹通常由root拥有(在我的大多数情况下都是如此).

webapp/
  shared     root:root
  releases   root:root

为了解决这个问题,我将把这些新文件夹的所有权更改为将要使用的用户.

webapp/
  shared     myuser:myuser
  releases   myuser:myuser

完成后,我将继续我的部署:更新

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐