新建 Laravel 出現500錯誤訊息
接觸Laravel蔡逼巴的我,
拉了前輩的專案來架改好.env檔後直接噴500,
也看不到錯誤訊息在哪裡,
好那先開啟顯示錯誤訊息看看
在app/Http/routes.php 直接塞
開啟錯誤訊息
ini_set("display_errors", "On");
error_reporting(E_ALL & ~E_NOTICE);
噴出
Fatal error: Uncaught UnexpectedValueException: The stream or file "/var/www/Myproject/storage/logs/laravel-2017-11-27.log" could not be opened: failed to open stream: Permission denied in /var/www/Myproject/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107 Stack trace: #0 /var/www/Myproject/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php(107): Monolog\Handler\StreamHandler->write(Array) #1 /var/www/Myproject/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\RotatingFileHandler->write(Array) #2 /var/www/Myproject/vendor/monolog/monolog/src/Monolog/Logger.php(337): Monolog\Handler\AbstractProcessingHandler->handle(Array) #3 /var/www/Myproject/vendor/monolog/monolog/src/Monolog/Logger.php(616): Monolog\Logger->addRecord(400, Object(UnexpectedValueException), Array) #4 /var/www/Myproject/vendor/laravel/framework/src/Illuminate/Log/ in /var/www/Myproject/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107Fatal error: Uncaught UnexpectedValueException: The stream or file "/var/www/Myproject/storage/logs/laravel-2017-11-27.log" could not be opened: failed to open stream: Permission denied in /var/www/Myproject/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107 Stack trace: #0 /var/www/Myproject/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php(107): Monolog\Handler\StreamHandler->write(Array) #1 /var/www/Myproject/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\RotatingFileHandler->write(Array) #2 /var/www/Myproject/vendor/monolog/monolog/src/Monolog/Logger.php(337): Monolog\Handler\AbstractProcessingHandler->handle(Array) #3 /var/www/Myproject/vendor/monolog/monolog/src/Monolog/Logger.php(616): Monolog\Logger->addRecord(400, Object(Symfony\Component\Debug\Exception\FatalErrorException), Array) #4 /var/www/Myproject/vendor/laravel/ in /var/www/Myproject/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107
看到…Log就想到 Storage/logs 是不是忘記給權限啦QQ
給權限也記得把專案的Owner改一下
$sudo chown -R www-data:www-data /var/www/your專案
CD進你的專案後輸入
$sudo chmod -R ug+rwx storage bootstrap/cache
重新整理OK