Php – “The stream or file “laravel.log” could not be opened: failed to open stream: Permission denied”

centoslaravel-5PHP

I upload the file to my cent OS server a few days ago, it was working fine, but from today I am getting the error.

The stream or file "/var/www/html/hasibtest/storage/logs/laravel.log"
could not be opened: failed to open stream: Permission denied

Where My log file is with 777 permission I am also trying with 0755, 0644

can anyone tell me how I can resolve this issue?

Best Answer

first try this to take ownership of the directory recursively

sudo chown -R $USER:www-data storage
sudo chown -R $USER:www-data bootstrap/cache

Then use the following to set proper directory access

chmod -R 775 storage
chmod -R 775 bootstrap/cache

Never Set dircetory permissions to 777 (Unless you know what you are doing)