I recently migrated multiple websites from my old shared hosting provider to my current virtual private server provider. I obviously use WordPress for my blog here at AnetComputers.com. I recently kept receiving this error when trying to upload images to the media library.
First I changed the “Store uploads in this folder” path in “Settings” then “Media” in the WordPress dashboard. This did NOT fix this problem. I went out and performed some search engine research and found a solution.
This fix is ONLY written for those of you that are using Centos Web Panel. You need to login via Secure SHell into your web server. You must be logged in with your root account or sudo as root.
Then you want to type the following command:
chown -R nobody:nginx /var/lib/nginx
You are changing the ownership for all files and folders under /var/lib/nginx to nobody. In a Linux environment different user accounts can have different permissions. By default the nginx account was the owner for all files and folders under /var/lib/nginx.
Nginx is a hyper text protocol web server. When I changed the owner of these files and folders from nginx to nobody, this resulted in that HTTP error disappearing. I was then able to successfully upload images to my WordPress websites.
When making changes to owners and groups on Linux, I would be careful as to performing these changes. You may want to monitor your WordPress website(s) more costly for awhile after making this change. You want to become certain that this does NOT cause other problems.
However, I have not noticed any other problems since making this change to the owner of the files for /var/lib/nginx. Finally, this fix was written exclusively for those of you using Centos Web Panel. Centos is a FREE open source website control panel alternative to cPanel.