ec2-user, apache and WordPress user:group permissions on Amazon Linux 2

There is a very (in)famous permissions glitch or settings if you host your WordPress website on Amazon Linux instance. If you keep user:group permissions to default ec2-user:apache then you are able to login to sftp and download upload files just fine but there are writable permissions issue on your WordPress website due to which you may not be able to install or update new plugins. Also media uploads might not work well.

To work around this issue you may be prompted to update user:group to apache:apache which fixes the write permissions for WordPress but then you are not able to download/upload files to your server.

I have had this issue quite a few time and this stackoverflow question addresses this issue well.  The first answer does not work however while the second answer by Chad Reitsma works for me. I am summing this answer  for my own reference here.

sudo chown -R ec2-user:apache /var/www/html
sudo chmod -R 755 /var/www/html

sudo find /var/www/html/ -type d -exec chmod 755 {} \;
sudo find /var/www/html/ -type f -exec chmod 644 {} \;

sudo chgrp -R apache /var/www/html
sudo chmod -R g+rw /var/www/html
sudo chmod -R g+s /var/www/html

In my case /var/www/html is the root folder where my WordPress site has been hosted.

Leave a Reply