简体   繁体   中英

Wordpress The uploaded file could not be moved to wp-content/uploads

So I have a pretty standard Wordpress site setup, however when trying to upload a photo I get an error saying

The uploaded file could not be moved to wp-content/uploads.

I'm running nginx and the user is nginx, I have the user and group of the directory set to nginx.

the directory and all sub-directories is set to 755, and still this error comes up, so i changed the directory permission to 777 to test and still the error pops up.

Obviously this is bad practice and should never be used but i was curious if maybe the user was wrong. I'm running CentOS 6.7

Just for notes the directory is /usr/share/nginx/site/wordpress/wp-content/uploads

please don't comment saying anything about changing the directory to 777.

Its kind of old question but I think it might be helpful for some one like me. I had same issue and I solved it by running following commands from terminal, please note your path of html may differ from mine. You need to figure this out.

sudo chown -R www-data:www-data /var/www/html

and after it

sudo chmod -R 774 /var/www/html

It's complaining that the user nginx does not have the permission to move the image file. Try changing the permissions of the image file(s), or changing the owner of these files to nginx.

=> php-fpm needs write access, not nginx. php-fpm process running as uid 1000, not as www-data/apache.

so you could change group like this: chgrp -R 1000 /usr/share/nginx/site/wordpress/wp-content/uploads

ideally you would limit what directory www-data/apache and php-fpm have write access to, Likewise limit it to an upload directory for example in WordPress.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM