Fixing WordPress Permission Issues on Amazon EC2
I’ve been working on a WordPress project lately that is housed on an Amazon EC2 server, using Bitnami. Overall, it’s a pretty awesome setup, giving me total free reign to setup the server how I need. Everything worked great on the QA server, but for some reason, after we moved the code to the production server, users started complaining about the inability to post any media (images, video, etc.) to their posts. They were getting a permissions error in WordPress trying to create the upload directory.
My initial thought was to use chmod to give all users write permissions to the folder in question. This couldn’t be done, however, as it opens up an obvious security hole.
So Next I checked out the QA site, and realized that the user and group owning the htdocs directory were daemon and bitnami, respectively. This was not the case on the prod server. So it became obvious that WordPress was hitting this directory as the daemon user, and did not have ownership rights to it. So I gave it to them:
Bash
chown -R daemon:bitnami /opt/bitnami/apps/wordpress/htdocs
And viola! The issue was resolved. This little jaunt down the rabbit hole, however, got me thinking about permissions as a whole when it comes to WordPress. I did some further reading and came across this great article regarding security on the wordpress platform. I highly suggest you give it a look.
If you only care about the meat and potatoes, as most developers often do, these two snippets are what you want. If you have shell access to your server, you can change file and folder permissions recursively with these bad boys, and set them to the correct permissions the WordPress team suggests.
For Folders:
find /path/to/your/wordpress/install/ -type d -exec chmod 755 {} ;
For Files:
find /path/to/your/wordpress/install/ -type f -exec chmod 644 {} ;
Good luck!
Comments (7)
Leave a Reply
This helped me. I had been starring at the bitnami:deamon permissions all week and had not realised they were the wrong way around. Thanks.
Link to commentNo problem Guy! Glad to help.
Link to commentI logged into my my ssh through amazon web service and try the command: chown -R daemon:bitnami /opt/bitnami/apps/wordpress/htdocs
My terminal printed out Operation not permitted
chown: changing ownership of not permitted.. How did you get around this?
Thanks
Link to commentVincent, try adding sudo before to execute the chown command with root user permission.
Example:
Link to commentsudo chown -R daemon:bitnami /opt/bitnami/apps/wordpress/htdocs
Thanks for the clarification Steve!
Link to comment@Vincent – it’s a sudo command, you need to be in super user mode
sudo chown -R daemon:bitnami /opt/bitnami/apps/wordpress/htdocs
Link to commentThanks for the help Brian!
Link to comment