Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

MariusGT's avatar

storage/framework/cache/data content under root user

Hi,

I noticed some of the files inside framework/cache/data are written under the root user:

drwxr-sr-x 3 root     www-data 4096 Jun  9 21:10 0c
drwxr-sr-x 3 root     www-data 4096 Jun  9 21:12 10
drwxr-sr-x 3 root     www-data 4096 Jun  9 21:09 65
drwxr-sr-x 3 root     www-data 4096 Jun  9 21:13 6b
drwxr-sr-x 3 root     www-data 4096 Jun  9 21:11 e4
drwxr-sr-x 3 www-data www-data 4096 Jun  9 21:09 e5

The problem with that is that deployer cannot delete those files owned by the root user, therefore it breaks my deployments.

I am currently running the following permissions on the storage folder:

run('sudo chgrp -R www-data {{release_path}}/storage');
run('sudo chmod -R g+w  {{release_path}}/storage');
run('sudo find {{release_path}}/storage -type d -exec chmod 2775 {} \;');
run('sudo find {{release_path}}/storage -type f -exec chmod ug+rw {} \;');

Anyone seen something similar?

Thanks!

0 likes
7 replies
sr57's avatar

@mariusgt

The problem with that is that deployer cannot delete those files

Why do you want to deploy these files? See the.gitignore that should exist in this directory.

MariusGT's avatar

Hi, @sr57

I'm not deplyoing those files, deployer has to delete previous builds but since those files have been created under the root user, it fails at that step.

MariusGT's avatar

@sr57 I kinda inherited the project, but I see there is a supervisor running on the server. Although I don't exactly know how to test if it writes in the cache folder.

sr57's avatar

I don't exactly know how to test if it writes in the cache folder.

Stop your jobs, delete your cache folders ... and see (after the "right" delay)

Snapey's avatar

some artisan commands as part of deployment might create cache entries

Best way is to php artisan cache:clear at the end of deployment.

MariusGT's avatar

Thank you all so much for your help! Sorry for the late reply.

Here is what I found out so far: Docker creates a cron that runs schedule:run. That cron seems to have been created as the root user. I changed that, so it is now created as www-data.

But what I see now is that the cron (although it says it's running) doesn't seem to actually create those cache files unless I manually got o the file and add an empty line at the end of it (there is one already). Delete it and just save the file again.

My crontab looks like this:

* * * * * /usr/local/bin/php -q -f /var/www/html/artisan schedule:run --no-ansi

#This is a comment to make sure the previous empty line is never stripped

Anyone knows why that may be?

Please or to participate in this conversation.