I'm having struggles with editing the Laravel cache, which is located in storage/framework/cache
. I've got a job running that saves to a certain cache, but every time the job runs, this error occurs:
ERROR: file_put_contents(/var/www/html/---/storage/framework/cache/data/3c/c7/3cc7fd54b5a3cb08ceb0754f58371cec1196159a): failed to open stream: Permission denied
Details
sudo chown -R www-data:www-data storage
in the folder the Laravel application is located, as well as sudo chmod -R 775 /home/<user>/<laravel folder>/storage
ls -lh /storage/framework/cache
returns the following: drwsrwsr-x 55 www-data www-data 4.0K Jan 18 20:56 data
.Any help is appreciated! Thank you in advance.
I cleared the cache completely using sudo php artisan cache:clear
. Afterwards, the problem never occurred.
Opposed to Ismoil's answer: never make the Laravel storage folder 777
. It poses a security risk.
1) If you take a look at your cache.php
config file you'll see that for the file driver the storage/framework/cache/data
folder is set for writing:
'file' => [
'driver' => 'file',
'path' => storage_path('framework/cache/data'),
],
That means that the permissions for that folder must be properly set so that the web server user can successfully write to that folder.
2) or you can just running this command for me it solved my problem
php artisan cache:clear
chmod -R 775 storage/
composer dump-autoload
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With