I have a problem with my (new/clean) Laravel (tried v5.2 and v5.5) application on Centos 7. It shows a 500 error when i visited the URL of the application with no error. I checked the log file of apache (/etc/httpd/logs/error-log.log) what contained the 2 errors bellow:
[Mon Dec 04 10:32:34.108956 2017] [:error] [pid 25889] [client 192.168.1.240:63437] PHP Fatal error: Uncaught UnexpectedValueException: The stream or file "/var/www/public/blog_project/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /var/www/public/blog_project/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107
Stack trace:
#0 /var/www/public/blog_project/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): MonologHandlerStreamHandler->write(Array)
#1 /var/www/public/blog_project/vendor/monolog/monolog/src/Monolog/Logger.php(337): MonologHandlerAbstractProcessingHandler->handle(Array)
#2 /var/www/public/blog_project/vendor/monolog/monolog/src/Monolog/Logger.php(616): MonologLogger->addRecord(400, Object(UnexpectedValueException), Array)
#3 /var/www/public/blog_project/vendor/laravel/framework/src/Illuminate/Log/Writer.php(202): MonologLogger->error(Object(UnexpectedValueException), Array)
#4 /var/www/public/blog_project/vendor/laravel/framework/src/Illuminate/Log/Writer.php(113): IlluminateLogWriter->writeLog('error', Object(U in /var/www/public/blog_project/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107
&
[Mon Dec 04 10:32:34.109334 2017] [:error] [pid 25889] [client 192.168.1.240:63437] PHP Fatal error: Uncaught UnexpectedValueException: The stream or file "/var/www/public/blog_project/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /var/www/public/blog_project/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107
Stack trace:
#0 /var/www/public/blog_project/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): MonologHandlerStreamHandler->write(Array)
#1 /var/www/public/blog_project/vendor/monolog/monolog/src/Monolog/Logger.php(337): MonologHandlerAbstractProcessingHandler->handle(Array)
#2 /var/www/public/blog_project/vendor/monolog/monolog/src/Monolog/Logger.php(616): MonologLogger->addRecord(400, Object(SymfonyComponentDebugExceptionFatalErrorException), Array)
#3 /var/www/public/blog_project/vendor/laravel/framework/src/Illuminate/Log/Writer.php(202): MonologLogger->error(Object(SymfonyComponentDebugExceptionFatalErrorException), Array)
#4 /var/www/public/blog_project/vendor/laravel/framework/src/Illuminate/Log/Writer.p in /var/www/public/blog_project/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107
To solve these problems i Googled a lot. Solutions i found where all related to permissions so I tried to set chmod 777 to all directories and files (for test purposes, not recommended at live environment!) in /var/www/public/blog_project but this did not solve the problem.
I also found that the owner/group could be the problem (unlikely with chmod 777 but ok) so I changed the owner and group to "apache". Unfortunately this did still not solve my problem.
I also tried a "php artisan cache:clear" (suggested in some topic what described the same problem as i have)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…