Drupal 9 Server Setup Basic Permissions

Submitted by slackstone on Wed, 11/24/2021 - 12:11

These are a few quick notes on setting ownership, sticky bits and permissions using "find".

Confirm you have the tools needed for working with Access Control Lists
> sudo apt install acl

Command for viewing current file/directory ACL permissions
> getfacl /opt/www/web

Command for setting proper directory ACL permissions
# group   
> sudo setfacl -d -m g::rwx /opt/www/web
# other
> sudo setfacl -d -m o::rx /opt/www/web

Command for RESETTING permissions in bulk using find
# setting directories to rwxrwsr-x+
# note, the "s" bit it the sticky bit for group permissions
# any user who creates a file or dir will be overridden by the Group setting; www-data
# d = setting directory to
# f = setting files to

sudo find /opt/www/web/ -type d -exec chmod 0775 {} +
sudo find /opt/www/web/ -type d -exec chown apache:dev {} +
sudo find /opt/www/web/ -type d -exec chmod g+s {} +
sudo find /opt/www/web/ -type f -exec chmod 0664 {} +
sudo find /opt/www/web/ -type f -exec chown apache:dev {} +