swagger's avatar

file_put_contents(...): failed to open stream: No such file or directory - Always this problem

I've tried everything and it seems I can't fix this problem.

It seems that if I try to connect with multiple IPs (I guess it creates multiple session) I get the following error:

file_put_contents(storage/framework/cache/data/52/55/52557bd14c017c25000a0012fa60d8a011764fb7): failed to open stream: No such file or directory

If I manully check the folder "55" it doesn't exists, so it makes sense that I get the error.

The point is that I don't know how to fix. I tried clearing the cache and this fixes the problem only temporarily!

I tried to change the permission to the storage folder but also this doesn't fix the problem.

Any ideas?

0 likes
6 replies
automica's avatar

Your storage folder and all inside should have 755 file permissions. Make sure you add the the -R flag to recursively set inside folders.

swagger's avatar

Already done..

chmod -R 775 storage

Edit: I've noticed that when I get that error the folder's group and owner is "root", while all the other working folder are owned /group www-data.

If I change those then it works again..

Now I have to understand why some folder are owned by root

swagger's avatar
swagger
OP
Best Answer
Level 1

Found the problem.. Really hard to find!

I run the task scheduler with the root account instead of the www-data .

So when setting the task scheduler, crontab should be modified by www-data

crontab -u www-data -e

1 like
cecil.merrell's avatar

they are owned by the user that installs them. to change them back to www-data(which is the user that php-fpm uses to run things), do the following

sudo chown -R www-data:www-data /var/www/laravel/vendor
sudo chown -R www-data:www-data /var/www/laravel/storage
sudo chown -R www-data:www-data /var/www/laravel/bootstrap/cache

Please or to participate in this conversation.