Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

laravel

When I navigate to Laravel app on my CentOS server, it gives HTTP ERROR 500

enter image description here

So, when I checked my server error log, it says this error

PHP Fatal error:  Uncaught UnexpectedValueException: The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /var/www/html/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107\nStack trace:\n#0 

I have already set 777 permission to storage and bootstrap directories.

This very Laravel application runs fine on another server. So, what's the big deal here ?

like image 806
Tharindu Thisarasinghe Avatar asked Mar 07 '23 12:03

Tharindu Thisarasinghe


1 Answers

This error can be fixed by disabling SE-Linux.

Check if it has been enabled by typing...

$ sestatus

So, disable it by typing...

# setenforce 0

It is said that the system needs to be restarted to to take effect the changes.

However, for me, restarting Apache was enough and fixed the problem :-)

Hope this helps!

like image 92
Tharindu Thisarasinghe Avatar answered Apr 28 '23 00:04

Tharindu Thisarasinghe