2011-06-10 65 views
4

我正在部署与乘客使用git和capistrano。我一直在努力做这项工作,并且没有取得太大进展,我已经敲了我的头几个小时。 cap部署:设置工作正常,但cap部署失败,权限问题。我尝试更改我的切片上的权限/所有权,但仍然失败。capistrano + git部署:无法创建工作树目录:权限被拒绝

 
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://[email protected]: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://[email protected]: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://[email protected]: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://[email protected]: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 

回答

10

不知道多少,这会有所帮助,但我始终有一个权限问题一deploy:setup

后,当你运行deploy:setup它创建初始你的目录。然而,它创建的那些文件夹通常由root拥有(无论如何,在我的大多数情况下)。

webapp/ 
    shared  root:root 
    releases root:root 

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

webapp/ 
    shared  myuser:myuser 
    releases myuser:myuser 

一旦做到这一点,我会用我的deploy:update

+7

只要你知道你可以在你的deploy.rb中设置'set:use_sudo,false'并且你不必手动改变权限。 – 2011-06-12 13:49:20

0

继续我刚刚遇到了这个问题为好。这是我发现的。

  • 如果您还没有能够成功部署,您可能需要暂时将您的部署文件夹(在服务器)到另一个位置(或者简单地将其重命名)
  • 请确保您有这里面你配方:set :use_sudo, false
  • 此再次运行:cap deploy:setup
  • 然后尝试cap deploy

另一个运行你一定会遇到其他麻烦机智h权限,如果您使用错误的用户构建了部署文件夹并告诉capistrano它具有sudo权限。

我希望这对你有效,因为它为我工作。

相关问题