Last active
August 30, 2023 15:56
-
-
Save monkishtypist/7e30ce125fe45bd7376a2e6adaa9143c to your computer and use it in GitHub Desktop.
WordPress file/folder permissions for Amazon EC2 Ubuntu instance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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/; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.