0
votes

I have a site myexample.com hosted on aws using EC2 Ubuntu stack. I installed wordpress and pointed blog.myexample.com to it.

The blog works fine except wordpress cannot write to the wp-uploads folder. Error:

Unable to create directory wp-content/uploads Is its parent directory writable by the server?

I have changed the permissions on the folders (777, 775) but it made no difference. It seems to be an ownership problem. Amazon recommend doing this: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/hosting-wordpress.html

Add the apache user to the www group.

[ec2-user wordpress]$ sudo usermod -a -G www apache

Change the file ownership of /var/www and its contents to the apache user.

[ec2-user wordpress]$ sudo chown -R apache /var/www

Change the group ownership of /var/www and its contents to the www group.

[ec2-user wordpress]$ sudo chgrp -R www /var/www

Change the directory permissions of /var/www and its subdirectories to add group write permissions and to set the group ID on future subdirectories.

[ec2-user wordpress]$ sudo chmod 2775 /var/www
[ec2-user wordpress]$ find /var/www -type d -exec sudo chmod 2775 {} +

Recursively change the file permissions of /var/www and its subdirectories to add group write permissions.

[ec2-user wordpress]$ find /var/www -type f -exec sudo chmod 0664 {} +

Is there a risk that I will affect the existing websites on this server? There are two.

Are there any risks to doing this?

I cannot afford to make a mistake and impact the existing sites. Thanks!

1
Secondly, this is off-topic for SO, it's not a coding / programming issue, it MIGHT be more appropriate for serverfault.comEpodax

1 Answers

1
votes

Careful. What you are suggesting probably won't affect existing sites, but it's not worth the risk. If you need to undo the change it's going to a whole lot more work.

Secondly allowing apache to write to all the folders and code on the server is a significant security risk. Anybody who gains access to your server code via a website hack will become the apache user and be able to re-write all your sites.

So. Just make the smallest change you need for Wordpress to work.
Find the folder

wp-content

Then from inside the wp-content folder.

sudo mkdir uploads
sudo chown apache:www uploads

This will be enough to make Wordpress uploads work on your site without impacting anything else.