Skip to content

Instantly share code, notes, and snippets.

@jasperf
Last active January 15, 2025 04:52
Show Gist options
  • Save jasperf/6d6937b7b513aca92fb8e5a93f1b8f1e to your computer and use it in GitHub Desktop.
Save jasperf/6d6937b7b513aca92fb8e5a93f1b8f1e to your computer and use it in GitHub Desktop.
User and ownership management to work with group www-data and user ubuntu on Amazon Sail setup
/**
* Amazon Sail User and Ownership Management Setup
*
* User Management: Adds ubuntu to the www-data group for group-based access.
* Ownership Management:
* Changes ownership of site directories to the appropriate users and groups (www-data and ubuntu).
* Permissions Management:
* Ensures that www-data has write access to the directories using g+w, which allows group members to modify files in the
* directory.
* Enforces consistent group ownership with g+s, ensuring new files and directories inherit the parent directory’s
* group ownership.
* Sets directory permissions (775) to balance security and functionality, allowing both controlled access and
* modification by the appropriate users and groups.
* Apache user is www-data in this scenario
*/
sudo usermod -a -G www-data ubuntu
sudo chown -R ubuntu:www-data /var/www/site.com/public_html
sudo chmod -R g+w /var/www/site.com/
sudo find /var/www/site.com/public_html -type d -exec chmod g+s {} +
sudo find /var/www/site.com/public_html -type d -exec chmod 775 {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment