Skip to content

Instantly share code, notes, and snippets.

@monkishtypist
Last active August 30, 2023 15:56
Show Gist options
  • Save monkishtypist/7e30ce125fe45bd7376a2e6adaa9143c to your computer and use it in GitHub Desktop.
Save monkishtypist/7e30ce125fe45bd7376a2e6adaa9143c to your computer and use it in GitHub Desktop.
WordPress file/folder permissions for Amazon EC2 Ubuntu instance
#!/bin/bash
# Location: Anywhere
# Add existing 'ubuntu' user to 'www-data' group
sudo usermod -a -G www-data ubuntu;
# Set the ownership of the files/directories
sudo chown -R www-data:www-data /var/www/html/;
# Set group ownership inheritance
sudo chmod g+s /var/www/html/;
# Set the permissions of the files/directories
sudo find /var/www/html/ -type d -exec chmod 755 {} \;
sudo find /var/www/html/ -type f -exec chmod 644 {} \;
# Give `write` permissions to the group (for editing files via FTP)
sudo chmod -R g+w /var/www/html/;
@monkishtypist
Copy link
Author

With the need to add and edit files on an AWS Ubuntu server for WordPress, I generally use the above permissions and settings to allow SFTP user access as well as local permissions for WP updates, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment