2014-01-19 37 views
0

所以我使用WP-Stack並嘗試從本地機器部署到EC2實例。Capistrano 2,SSH,Mac,EC2 - 寫入權限被拒絕

伊夫遵循Capistrano酒店的SSH文學,我可以例如通過只是運行SSH和用戶/ IP

我已經創建的用戶我EC2服務器上的「部署」獲取服務器信息,我已確保它有權限寫我想要的文件夾(事實上,我可以進去,並從CL手動進入「mkdir/production /」,沒有任何問題來創建目錄Capistrano正在嘗試創建.Ive在網上搜索和搜索,我無法找到任何特定於我的問題。大多數似乎是文件夾的錯誤。

所以我有這個由deploy.rb

# 
set :user, "deploy" 
set :use_sudo, false 
set :deploy_via, :remote_cache 
set :copy_exclude, [".git", ".gitmodules", ".DS_Store", ".gitignore"] 
set :keep_releases, 5 

after "deploy:update", "deploy:cleanup" 
after "deploy:update_code", "shared:make_shared_dir" 
after "deploy:update_code", "shared:make_symlinks" 
after "deploy:update_code", "db:make_config" 
after "deploy", "memcached:update" 

# Pull in the config file 
loadFile 'config/config.rb' 

和配置

# Customize this file, and then rename it to config.rb 

set :application, "myapp" 
set :repository, "[email protected]:user/mygit.git" 
set :scm, :git 
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none` 

# Using Git Submodules? 
set :git_enable_submodules, 1 

# This should be the same as :deploy_to in production.rb 
set :production_deploy_to, '/var/www/vhost/i-16852366/production/' 

# The domain name used for your staging environment 
set :staging_domain, 'stage.domain.com' 

# Database 
# Set the values for host, user, pass, and name for both production and staging. 
set :wpdb do 
{ 
    :production => { 
     :host  => 'user.us-east-1.rds.amazonaws.com', 
     :user  => 'user', 
     :password => 'pass', 
     :name  => 'name', 
    }, 
    :staging => { 
     :host  => 'user.us-east-1.rds.amazonaws.com', 
     :user  => 'user', 
     :password => 'pass', 
     :name  => 'name2', 
    } 
} 
end 

# You're not done! You must also configure production.rb and staging.rb 

終於爲生產

# This file is only loaded for the production environment 
# Customize it and rename it as production.rb 

# Where should the site deploy to? 
set :deploy_to, '/var/www/vhost/i-16852366/production/' 

# Now configure the servers for this environment 

# OPTION 1 

# role :web, "your web server IP address or hostname here" 
# role :web, "second web server here" 
# role :web, "third web server here, etc" 

# OPTION 2 

# If your web servers are the same as your memcached servers, 
# comment out all the "role" lines and use "server" lines: 

server "54.242.153.162", :web, :memcached 

但是當我嘗試「帽部署:安裝」或「帽部署:檢查」無法寫入文件夾我可以通過部署用戶的命令提示符創建

servers: ["54.242.153.162"] 
[54.242.153.162] executing command 
** [out :: 54.242.153.162] mkdir: cannot create directory `/var/www/vhost': Permission denied 
** [out :: 54.242.153.162] mkdir: cannot create directory `/var/www/vhost': Permission denied 
** [out :: 54.242.153.162] mkdir: cannot create directory `/var/www/vhost': Permission denied 
command finished in 600ms 
failed: "sh -c 'mkdir -p /var/www/vhost/i-16852366/production/ /var/www/vhost/i- 16852366/production/releases /var/www/vhost/i-16852366/production/shared && chmod g+w  /var/www/vhost/i-16852366/production/ /var/www/vhost/i-16852366/production/releases /var/www/vhost/i-16852366/production/shared'" on 54.242.153.162 

任何想法?是否由於.tem文件未被使用?如果是這樣的話,我找不到說明如何使用它的教程。

回答

0

通過SSH訪問EC2實例使用常規用戶 - 例如,對於Amazon AMI,您將以ec2用戶身份登錄。

/var/www屬於root,所以ec2-user將無法創建子目錄。

我改變此行真正的開始:

set :use_sudo, false 
+0

我的圖像使用root作爲主要用戶。我沒有使用亞馬遜AMI,我使用animo來wordpress Nginx之一,http://megumi-cloud.com/category/blog/ 我創建了一個部署用戶,並聲明它可以ssh在很好並創建它在Web根目錄中擁有的目錄,我的用戶設置沒有任何問題。哦,我試圖將sudo虛假爲真,但仍然無效。 – Daniel

+0

/var/www上有什麼權限? – chris