Solved: WordPress Cannot Upload Images (NGINX)

Symptom: WordPress running on NGINX cannot upload images or files. You may see an error message that tells you “permission denied” in the media uploader. Naturally you check permissions on your uploads folder, but the permissions appear correct. You might have even tried setting chmod permissions to 777. However, none of this will help if NGINX, your web server, is denying WordPress the ability to upload to it’s temp directory.

Your php error log may contain something like this.

open() "/var/lib/nginx/tmp/client_body/*" failed (13: Permission denied)

View the temp folders current ownership and permissions. This is where the root of the issue is.

sudo ls -l /var/lib/nginx/

You should get something like this back:

drwx------ 7 owner group 4096 Jun 28 18:52 tmp

Specifically, look at the owner and group. This needs to be set to your WordPress application user and group. Not sure what that is? Go take a look.

sudo ls -l /var/www/pathtowordpress/wp-content

Set the ownership of your temp directory to match the wp-content folder.

sudo chown yourwebapp:yourwebapp /var/lib/nginx/tmp

At this point, if everything went as planned, you should be able to upload images and other files.