如果Laravel 報錯 file_put_contents(): failed to open stream


問題解決方法

  1. 執行命令 php artisan cache:clear 並賦予 /storage 文件夾讀寫權限: chmod -R 777 storage

  2. 若在執行 php artisan cache:clear 時出現錯誤:Uncaught UnexpectedValueException: The stream or file "/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:87,需要賦予 /storage/log 讀寫權限: chmod -R 777 storage/logs

  3. 此時再執行 php artisan cache:clear,若繼續出錯[ErrorException] file_put_contents(/bootstrap/cache/services.php): failed to open stream: Permission denied,需要賦予 bootstrap/cache 讀寫權限:chmod -R 777 bootstrap/cache

  4. 再執行 php artisan cache:clear,若仍然出錯:[PDOException] SQLSTATE[HY000] [1045] Access denied for user 'xxx'@'127.0.0.1' (using password: YES),則需要查看 laravel 的數據庫配置是否正確。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM