@see https://www.drupal.org/node/244924
Copy the code above to a file, name it fix-permissions.sh and run it as follows:
sudo bash fix-permissions.sh --drupal_path=your/drupal/path --drupal_user=your_user_name
Note: The server group name is assumed www-data, if it differs use the --httpd_group=GROUP argument.
If you have sufficient privileges on your server:
- Place the file in
/usr/local/bin sudo chown root:root /usr/local/bin/fix-permissions.shsudo vi /etc/sudoers.d/fix-permissionsand enter the following line in the file:user1, user2 ALL = (root) NOPASSWD: /usr/local/bin/fix-permissions.sh- Save the file and then
sudo chmod 0440 /etc/sudoers.d/fix-permissions
Note: Substitute your desired comma separated list of users where you see user1, user2 above. Alternatively, you could enter an ALIAS for a user list. Run man sudoers for more information on formatting the line.
What the /etc/sudoers.d/fix-permissions accomplishes is making the script available to a set of users via the sudo command without having to enter a password.
Assuming that /usr/local/bin is in the user's path (and it should be), then the script can be run from anywhere using:
sudo fix-permissions.sh \
--drupal_path=/path/to/the/drupal/install \
--drupal_user=your_desired_user