'AWS EC2 Ubuntu File permissions issue
I'm running a EC2 instance with:
Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-119-generic x86_64) Bitnami LAMP 5.6.30-5
My problem
I have a Wordpress site that isn't working very well on the backend, so I decided to update and I get an error "Can not create the directory..." when updating. So I did a research and it's related to file permissions. So I get to this conclusion:
I having the following issues with the file permissions:
Can't write files from server
I used is_writable() (PHP) to detect if server can edit and it returns false.
Can edit files from Filezilla
I login to the server with the "bitnami" user and everything works good.
I tried
sudo chown -R bitnami:www-data htdocs/
I added the default user "bitnami" to the www-data group and changed the /htdocs owner. And, yes the user is in the www-data group.find htdocs/ -type d -exec sudo chmod 2775 {} +
Changed directory permissionsfind /var/www -type f -exec sudo chmod 0664 {} +
Changed the files permissions
How to solve this?
I tried all that and also giving the owner to root:root, www-data:www-data and bitnami:bitnami.
If someone knows the original user and group owner of the /htdocs folder I could try a test, but I forgot.
I would appreciate if anyone can help me to solve this. I just want to be able to write/edit files from server side.
Many thanks.
Solution 1:[1]
I solved this by doing the following:
- Set htdocs owner to bitnami:bitnami
sudo chown -R bitnami:bitnami htdocs/
- Inside /htdocs, changed file and directories owner to bitnami:daemon
sudo chown -R bitnami:daemon
- Changed files and directories permissions
sudo find * -type d -print0 | xargs -0 chmod 0755 # for directories
sudo find . -type f -print0 | xargs -0 chmod 0644 # for files
- Changed wp-content directories permissions to 775
sudo find wp-content/ -type d -exec chmod 0775 {} \;
And with that now I'm able to edit and upload via FTP and in the WP admin dashboard.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |