Image Uploads Not Working on WordPress AWS LAMP

Background: We recently installed a new AWS LAMP PHP 7 server on their Lightsail platform. Initially we didn’t want to go with the base WordPress Image. After a while it was decided to add WordPress manually by following the WordPress instructions here. Once that was completed we noticed that we could not upload images to the wordpress site.

Looking through the various articles online we found many mentioning editing the permissions for the wp-content/uploads folder. It turns out that wasn’t really the problem for this type of server. We manually ftp’d the WordPress files as an admin up the server and therefore the files / ownership was for the bitnami admin account and not the apache bitnami daemon user group.

Here is how we fixed it.. Note the ownership group changed between screen output 1 and 2. Also be aware your paths might be different so update them as necessary..

first get the current permissions as a backup:

sudo ls -l /opt/bitnami/apache2/htdocs
sudo ls -l /opt/bitnami/apache2/htdocs/wp-config.php


screen output

$ sudo ls -l /opt/bitnami/apache2/htdocs
total 224
-rw-r–r– 1 bitnami bitnami 1150 Mar 24 21:42 favicon.ico
-rw-r–r– 1 bitnami bitnami 405 Feb 6 2020 index.php
-rw-r–r– 1 bitnami bitnami 19915 Jan 1 00:19 license.txt
-rw-r–r– 1 bitnami bitnami 7345 Dec 29 20:14 readme.html
-rw-r–r– 1 bitnami bitnami 7165 Jan 21 01:37 wp-activate.php
drwxr-xr-x 9 bitnami bitnami 4096 Mar 9 20:19 wp-admin
-rw-r–r– 1 bitnami bitnami 351 Feb 6 2020 wp-blog-header.php
-rw-r–r– 1 bitnami bitnami 2328 Feb 17 13:08 wp-comments-post.php
-rw-r–r– 1 bitnami bitnami 3079 Mar 24 19:15 wp-config.php
-rw-r–r– 1 bitnami bitnami 2913 Feb 6 2020 wp-config-sample.php
drwxr-xr-x 5 bitnami bitnami 4096 Mar 24 21:54 wp-content
-rw-r–r– 1 bitnami bitnami 3939 Jul 30 2020 wp-cron.php
drwxr-xr-x 25 bitnami bitnami 12288 Mar 9 20:19 wp-includes
-rw-r–r– 1 bitnami bitnami 2496 Feb 6 2020 wp-links-opml.php
-rw-r–r– 1 bitnami bitnami 3313 Jan 10 19:28 wp-load.php
-rw-r–r– 1 bitnami bitnami 44993 Feb 2 18:13 wp-login.php
-rw-r–r– 1 bitnami bitnami 8509 Apr 14 2020 wp-mail.php
-rw-r–r– 1 bitnami bitnami 21125 Feb 2 00:10 wp-settings.php
-rw-r–r– 1 bitnami bitnami 31328 Jan 27 21:03 wp-signup.php
-rw-r–r– 1 bitnami bitnami 4747 Oct 8 21:15 wp-trackback.php
-rw-r–r– 1 bitnami bitnami 3236 Jun 8 2020 xmlrpc.php
$ sudo ls -l /opt/bitnami/apache2/htdocs/wp-config.php
-rw-r–r– 1 bitnami bitnami 3079 Mar 24 19:15 wp-config.php


The commands to change ownership to the apache daemon user group and modify the rest of the site permissions to most restrictive according to bitnami’s docs.

sudo chown -R bitnami:daemon /opt/bitnami/apache2/htdocs
sudo chmod -R g+w /opt/bitnami/apache2/htdocs
sudo chmod 644 /opt/bitnami/apache2/htdocs/wp-config.php


screen output of permissions after they were changed

$ sudo ls -l /opt/bitnami/apache2/htdocs
total 224
-rw-rw-r-- 1 bitnami daemon 1150 Mar 24 21:42 favicon.ico
-rw-rw-r-- 1 bitnami daemon 405 Feb 6 2020 index.php
-rw-rw-r-- 1 bitnami daemon 19915 Jan 1 00:19 license.txt
-rw-rw-r-- 1 bitnami daemon 7345 Dec 29 20:14 readme.html
-rw-rw-r-- 1 bitnami daemon 7165 Jan 21 01:37 wp-activate.php
drwxrwxr-x 9 bitnami daemon 4096 Mar 9 20:19 wp-admin
-rw-rw-r-- 1 bitnami daemon 351 Feb 6 2020 wp-blog-header.php
-rw-rw-r-- 1 bitnami daemon 2328 Feb 17 13:08 wp-comments-post.php
-rw-r--r-- 1 bitnami daemon 3079 Mar 24 19:15 wp-config.php
-rw-rw-r-- 1 bitnami daemon 2913 Feb 6 2020 wp-config-sample.php
drwxrwxr-x 5 bitnami daemon 4096 Mar 24 21:54 wp-content
-rw-rw-r-- 1 bitnami daemon 3939 Jul 30 2020 wp-cron.php
drwxrwxr-x 25 bitnami daemon 12288 Mar 9 20:19 wp-includes
-rw-rw-r-- 1 bitnami daemon 2496 Feb 6 2020 wp-links-opml.php
-rw-rw-r-- 1 bitnami daemon 3313 Jan 10 19:28 wp-load.php
-rw-rw-r-- 1 bitnami daemon 44993 Feb 2 18:13 wp-login.php
-rw-rw-r-- 1 bitnami daemon 8509 Apr 14 2020 wp-mail.php
-rw-rw-r-- 1 bitnami daemon 21125 Feb 2 00:10 wp-settings.php
-rw-rw-r-- 1 bitnami daemon 31328 Jan 27 21:03 wp-signup.php
-rw-rw-r-- 1 bitnami daemon 4747 Oct 8 21:15 wp-trackback.php
-rw-rw-r-- 1 bitnami daemon 3236 Jun 8 2020 xmlrpc.php
$ sudo ls -l /opt/bitnami/apache2/htdocs/wp-config.php
-rw-r--r-- 1 bitnami daemon 3079 Mar 24 19:15 wp-config.php


Summary – If you manually install WordPress on a Bitnami LAMP server you will need to change the permission for files so the Bitnami Apache Daemon group has proper access.

Leave a comment