dimanche 27 avril 2014

OSX - Capistrano 2, SSH, Mac, EC2 - autorisation refusée à l'écriture - Stack Overflow


So I'm using WP-Stack and trying to deploy from my local machine to an EC2 instance.


Ive follow capistrano's SSH literature and I can for instance get the server info by just running SSH and the user/IP


I have created the user 'deploy' on my EC2 server, I have ensured it has permissions to write the folders I want (infact I can go in and manually from CL do "mkdir /production/" without problems to create the directory Capistrano is trying to make. Ive searched and searched online and I can't find anything specific to my issue. Most seem to be folder's having the wrong errors.


So I have this in by 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'

and in config


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

set :application, "myapp"
set :repository, "git@bitbucket.org: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

and finally for production


# 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

But when I try 'cap deploy:setup' or 'cap deploy:check' it can't write to folders I can create from command prompt with the deploy user


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

Any ideas? Is it due to the .tem file not being used? I can't find a tutorial that shows how to use it if so.




Access via SSH to an EC2 instance uses a regular user - for the Amazon AMI, for example, you will log in as ec2-user.


/var/www is owned by root, so the ec2-user will not be able to create a subdirectory.


I'd start by changing this line to true:


set :use_sudo, false


So I'm using WP-Stack and trying to deploy from my local machine to an EC2 instance.


Ive follow capistrano's SSH literature and I can for instance get the server info by just running SSH and the user/IP


I have created the user 'deploy' on my EC2 server, I have ensured it has permissions to write the folders I want (infact I can go in and manually from CL do "mkdir /production/" without problems to create the directory Capistrano is trying to make. Ive searched and searched online and I can't find anything specific to my issue. Most seem to be folder's having the wrong errors.


So I have this in by 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'

and in config


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

set :application, "myapp"
set :repository, "git@bitbucket.org: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

and finally for production


# 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

But when I try 'cap deploy:setup' or 'cap deploy:check' it can't write to folders I can create from command prompt with the deploy user


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

Any ideas? Is it due to the .tem file not being used? I can't find a tutorial that shows how to use it if so.



Access via SSH to an EC2 instance uses a regular user - for the Amazon AMI, for example, you will log in as ec2-user.


/var/www is owned by root, so the ec2-user will not be able to create a subdirectory.


I'd start by changing this line to true:


set :use_sudo, false

Related Posts:

0 commentaires:

Enregistrer un commentaire