Question

This is a weird one.

Wordpress by default stores uploaded media in monthly sub-directories of the uploads directory. Eg wp-content/uploads/2016/07/

On one of my sites, this directory's owner gets set to "root:root", which means that nothing can be uploaded to the directory via the web server.

Any ideas what might cause this behaviour? I can imagine a cron script creating this behaviour, but I don't see how Wordpress itself should be able to create a directory owned by root.

Was it helpful?

Solution

I've had the same problem, and in my case it was the Wordpress cronjob. I was calling the wp-cron.php as a root cron job, and this script also generates the monthly upload folder.

If you call wp-cron.php via cronjob you need to do this as the web server user (or i.e. in Plesk the site user and group psacln). The owner of the created monthly folder is always the user the wp-cron.php is called from.

OTHER TIPS

I had the same problem, also a cronjob, but WP CLI was the issue. The cronjob was running a 'wp plugin' command every month, the 'wp plugin' command was creating the monthly folder owned by the same user that ran the cronjob -- root.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top