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

Viewed 16232

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 ?

2 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!

If your application is laravel and you use sail so add these lines in end of .env file:

WWWGROUP=1000
WWWUSER=1000

I know its late to answer but maybe helps for others.

Related