Easily Fix File and Folder Permissions Denied Errors in Bitnami WordPress

In this video I will show you how to fix file and folder permission issues on your Lightsail WordPress install.

If you manage a WordPress site using the Bitnami blueprint in Lightsail, you may run into permission errors. These errors are mostly in two areas:
1. If you are trying to update a file using SFTP or SSH; you get a permission denied error and that prevents you from updating files in WordPress installation folder.
2. If you have a plugin or theme that needs to write to a folder and it is getting a permission denied error.

In both of these cases, most of the time the problem comes down to permissions.

Bitnami sets up two users and groups in its Lightsail image. The Bitnami user which is what you would use to SFTP or SSH and modify files and Daemon user which is what the Apache web server runs as and access the WordPress files and folder to serve pages for your website.
So how do the permissions get messed up? Its probably a variety of scenarios but likely if you go into the wp-admin and update plugins, themes then the web server may set the plugins folder permissions to daemon. And therefore if you login as Bitnami user you will not be able to modify those same files. This can happen in reverse too where you may create a folder that is meant to be accessed by some PHP code and it isn’t able to do so because the owner is set to Bitnami. There could be other reasons too.

There are easy steps to fix this and below are those steps:

Steps:

  1. SSH into your server using Bitvise SSH client or the web-based SSH client in Lightsail
  2. Set the owner to user bitnami and group daemon
    1. sudo chown -R bitnami:daemon /opt/bitnami/apps/wordpress/htdocs
  3. Set the write permissions for folders
    1. sudo find /opt/bitnami/apps/wordpress/htdocs -type d -exec chmod 775 {} \;
  4. Next the WordPress files needs read and write permissions for the owner and group so set that with this command:
    1. sudo find /opt/bitnami/apps/wordpress/htdocs -type f -exec chmod 664 {} \;