Question

Constantly Having to Reclaim Wp-Uploads Folder Permissions

I have started noticing this with a few of my OpenLiteSpeed wordpress sites now, running WP 6+.

Each month when the new monthly wp-uploads directory is created (eg October/November /uploads/2021/10/ /2021/11 etc) , the permissions are WRONG.

I get the error “the uploaded file could not be moved to…” and it appears that the folder has been created with root as the owner, and not www-data.

Numerous times I have run the command:

sudo chown -R www-data /var/www/mysite/wp-content/uploads

I recursively run this command on both the uploads directory and wp-content parent directory, but it seems i’m having to run it every month on the new folder created in uploads.

Obviously something is wrong here, can anyone possibly advise what the problem is here?

Not entirely sure how to add an image here but all of my folders are www-data:www-data, it seems the new ones are being created with the wrong permissions.

Any advice much appreciated. Thanks. Its getting annoying and i’m losing business because my website relies on users adding content and listings, and if they cant upload images i’ll be losing money.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

alexdo
Site Moderator
Site Moderator badge
November 7, 2022

Hello there,

This should be related to having WordPress cron jobs running as the root username.

We also have an article which covers this issue and possible ways to sort out the problem which you can check here

https://www.digitalocean.com/community/tutorials/how-to-fix-the-uploaded-file-could-not-be-moved-to-in-wordpress

Regards

Hi @mburdett555,

I understand you. Specifically what is the user that assigns you in the folders? Are you using PHP-FPM ?

I recommend you check out Hardening Wordpress, provides a lot of information on the subject.

Let me know more information.

Sergio Turpín

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel
Get started for free

Enter your email to get $200 in credit for your first 60 days with DigitalOcean.

New accounts only. By submitting your email you agree to our Privacy Policy.

© 2023 DigitalOcean, LLC.