Before Updating – Fix Permissions

Here is the cheatsheet I use to set permissions and SElinux before I update the site. These commands assume your wordpress root directory is /var/www/html.

#Apache Needs To Own The Files
sudo chown apache:apache -R /var/www/html/

#Set wordpress directory permissions
find /var/www/html -type d -exec chmod 755 {} \;

#Set wordpress file permissions
find /var/www/html -type f -exec chmod 644 {} \;

#SELinux - Set Directories To Be Writable
sudo chcon -t httpd_sys_rw_content_t /var/www/html/ -R

After Updating – Harden WordPress

#SELinux - Restore Default SELinux Types
sudo restorecon -R /var/www/html 

#SELinux - Set Uploads Directory To Be Writable
sudo chcon -t httpd_sys_rw_content_t /var/www/html/wp-content/uploads -R

#Wordpresss Permission - wp-config.php
chmod 400 wp-config.php


References

WordPress File Permissions