Drupal - Drush and user permissions

Arguably, a much more straightforward approach is to not muck with your user's group assignments at all and instead run drush as the web server user (ie: apache, www-data).

Use sudo:

sudo -u apache drush

or on debian/ubuntu:

sudo -u www-data drush

Create a command alias:

Then, to ensure that you always run drush like that, add an alias:

echo "alias drush='sudo -u apache drush'" >> ~/.bash_aliases 

or on debian/ubuntu:

echo "alias drush='sudo -u www-data drush'" >> ~/.bash_aliases 

Now when running any drush command, you'll be prompted for your password by sudo, and the command will run as the web server user. No more permissions problem reading and writing files.


Though the other answer is informative, I now use the proper user permission as described in

Securing file permissions and ownership

  • https://www.drupal.org/node/244924

Which opens with

The server file system should be configured so that the web server (e.g. Apache) does not have permission to edit or write the files which it then executes. That is, all of your files should be 'read only' for the Apache process, and owned with write permissions by a separate user.

Tags:

Drush

Files