Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When Capistrano3 does mkdir, permission denied

When I did bundle exec cap production deploy, i got error messages like mkdir: cannot create directory /usr/share/nginx/www/appname/releases/20131216155457: Permission denied

Capistrano3 doesn't have set use_sudo and default_run_options. I read that Passwordless sudo is better, so I did visudo username ALL=NOPASSWD:ALL, but still I got the same errors.

set :application, 'appname.com'
set :repo_url, '[email protected]:user/myapp.git'
set :user, 'username' 
set :branch, 'master'


set :deploy_to, '/usr/share/nginx/www/appname'
set :keep_releases, 5

namespace :deploy do

 desc 'Restart application'
 task :restart do
   on roles(:app), in: :sequence, wait: 5 do
   end
 end

 after :restart, :clear_cache do
   on roles(:web), in: :groups, limit: 3, wait: 10 do
   end
 end

 after :finishing, 'deploy:cleanup'

end

Does anyone give me any advice around this problem? Thank you for your help.

like image 512
Yuki Ishikawa Avatar asked Dec 16 '13 16:12

Yuki Ishikawa


People also ask

How do I fix permission denied mkdir?

[ErrorException] mkdir(): Permission denied Create a new folder, say 'myproject and run sudo chmod 777 myproject . Then move to 'myproject' folder and create project. To solve this problem, go into your laravel project, make your public directory writable.

How do you fix mkdir Cannot create directory?

Resolving The Problem Simply log in as super user “su” and use “chmod 777” to set the directory permissions of where you wish the rational directory to be created. Once done, you can re-enter the original directory again and the install will continue using the same directory.

Can not create directory permission denied?

If you receive an error telling you that you do not have permissions to create a directory or to write a file to a directory, this is likely an indication that your script is attempting to write to a directory that you do not own.

Can not Create directory Permission denied Linux?

mkdir: cannot create directory – Permission denied The reason for this error is that the user you're running the mkdir as, doesn't have permissions to create new directory in the location you specified. You should use ls command on the higher level directory to confirm permissions.


1 Answers

Try setting the group and owner of the appname folder

chown deployer:www-data -R /usr/share/nginx/www/appname

where deployer is your deploy user and group is the user group

like image 110
MaximusDominus Avatar answered Oct 19 '22 23:10

MaximusDominus