Fix File and Folder Permissions for WordPress on Bitnami GCP

For the optimal and secure WordPress permissions. You can run the following commands by SSH’ing into the linux terminal (I’m using Debian 8 on the Google Compute Engine). We may have to change the Owner and Group of the WP folders, depending on how you’ve uploaded your WordPress site.

Let’s fix the ownership and group permissions on Bitnami

To rewrite all files and folders ownership and group use the following. Remember to change your owner/group and folder path, as it may not be the same.

sudo chown -R daemon:daemon /opt/bitnami/apps/wordpress/htdocs

Next we need to change all the folder permissions to 755 (drwxr-xr-x). The command rewrites the permissions for all sub directories for the selected path to your root WordPress install.

sudo find /opt/bitnami/apps/wordpress/htdocs -type d -exec chmod 755 {} \;

We do the same for all files and files in the subdirectories of htdocs. They should be set to 644 (-rw-r–r–).

sudo find /opt/bitnami/apps/wordpress/htdocs -type f -exec chmod 644 {} \;

Some plugins may ask for additional write permissions on specific folders or files. You can give them manually for security. use 775 for folders.

Now restart Apache the Bitnami way

sudo /opt/bitnami/ restart apache

Still can’t update WordPress plugins? Quick fix

If you are having issues with automatic plugin updates or downloading from the WordPress Repo, then your websever owner or group name may be wrong. Double check that you are using the correct details. As a quick fix for the WordPress permissions, you can give all groups write permissions using the following.

sudo chmod g+w /opt/bitnami/apps/wordpress/htdocs -R

A word of caution

Don’t make changes you aren’t sure of (without backups ?). Check the owner and groups of your webhost. The above tutorial is for WordPress by Bitnami on the Google Could Platform. I recommend reading up on Hardening WordPress and security practices for those who like double checking.