環境
- PHP 7.4.4
- Laravel 7.5.1
エラー
The stream or file "/work/backend/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied
in /work/backend/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php (line 110)
in /work/backend/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php -> write (line 42)
in /work/backend/vendor/monolog/monolog/src/Monolog/Logger.php -> handle (line 323)
in /work/backend/vendor/monolog/monolog/src/Monolog/Logger.php -> addRecord (line 541)
in /work/backend/vendor/laravel/framework/src/Illuminate/Log/Logger.php -> error (line 174)
in /work/backend/vendor/laravel/framework/src/Illuminate/Log/Logger.php -> writeLog (line 87)
in /work/backend/vendor/laravel/framework/src/Illuminate/Log/LogManager.php -> error (line 547)
in /work/backend/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php -> error (line 122)
原因
storage
ディレクトリに書き込み権限がないため。
対策
$ chmod -R 775 storage bootstrap/cache
storage
と bootstrap/cache
の2つのディレクトリは書き込み権限を付与してあげる。