Capistrano mkdir permission denied

Kamil Lelonek picture Kamil Lelonek · Jun 28, 2014 · Viewed 12.1k times · Source

When I run cap production deploy I get cannot create directory ‘/var/www/application/repo’: Permission denied.

So far I've created deploy user like:

adduser deploy
adduser deploy sudo

and I use this user in Capistrano.

Indeed, when I log to [email protected] I don't have sudo permission by default, every time I need to enable it explicitly like sudo su.

I see two possible solutions:

  1. Enable sudo in Capistrano
  2. Enable sudo in Ubuntu

Unfortunately I don't know how to do neither of them.

Answer

shankardevy picture shankardevy · Jun 29, 2014

By default Capistrano 3 deploys to /var/www which is not writable by deploy user. You need to change the ownership of /var/www to deploy user using the following command.

sudo chown deploy:deploy /var/www/

After this, you should be able to deploy your app without permission error.