Setting up folder permissions for WordPress on Amazon EC2 (Amazon Linux)

Are you facing file uploading errors or not able to install plugins or upload files through ftp to your EC2 installation of WordPress? Possibly folder permissions?? Read on.

I recently setup a new WordPress website on an ec2 instance. I tried to install a plugin by uploading it from admin end but it faced an error, something like, “could not create directory”.

I changed permissions to 755 for folder and 644 for file, and did some more tweaks and it started to work. But then the uploading files through ftp started to fail with bad file permission errors.

Solution:

Here is what I did to fix all WordPress and FTP permission errors to make it
working smoothly.

I assume that apache is the web user and ec2-user is the default ssh/ec2-user for your ec2 instance apache webserver setup

to add ec2-user to apache user group

useradd -G apache ec2-user

Now run following command to assign appropriate user rights and folder/file permissions

sudo chown -R ec2-user:apache public_html
sudo chmod -R 755 public_html

sudo find public_html -type d -exec chmod 755 -R {} \;
sudo find public_html -type f -exec chmod 644 -R {} \;

sudo chgrp -R apache public_html
sudo chmod -R g+rw public_html
sudo chmod -R g+s public_html

It should fix the issues with your wordpress folder permissions on your ec2 installation.

Leave a Reply