Some directories and files in storage created by root

I am experiencing an issue that I can’t figure out and it prevents me from using the self updater properly as some files are not writable. This is because invoiceninja goes to update as the web user, but some directories and files have root:root permissions.

It seems that some directories and files in the storage directory end up being created as root:root but I’m not sure why because everything else runs and is created as the web user for that domain as expected. This is through Virtualmin.

Any ideas?


Have you run these commands to set the file permissions:

sudo chown -R www-data:www-data /var/www/html
sudo find ./ -type d -exec chmod 755 {} \;

Yes, I can do that manually and then update but the issue is invoice ninja creates these backup files in storage as the root user from time to time and I have to keep fixing permissions.

@david do you have any thoughts?


Are you running your crons under the webuser to root? It may be that a cron is running a root hence the permissions of the folders will be created by the same user.

I had a duplicate cronjob running as root for invoiceninja and I think this is what caused that issue. I removed it and retested, caches and other files are now created as the webuser. I think that solved it, thanks David.