Laravel 报错 file_put_contents(): failed to open stream 的解决方法
1. 问题解决方法
执行命令
php artisan cache:clear
并赋予/storage
文件夹读写权限:chmod -R 777 storage
;若在执行
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
;此时再执行
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
;再执行
php artisan cache:clear
,若仍然出错:[PDOException] SQLSTATE[HY000] [1045] Access denied for user 'xxx'@'127.0.0.1' (using password: YES)
,则需要查看 laravel 的数据库配置是否正确。
2. 参考
DB.Reid
WeCenter 迁移踩坑备忘
dailybird阅读 2.5k
Laravel 配合 jwt 使用
开源到赞 1阅读 3.2k
Laravel常用代码合集
开源到赞 1阅读 1.5k
Eloquent ORM 的 where 查询条件的解析器增强版
big_cat赞 1阅读 1.7k
laravel 文档摘要2
changsj阅读 499
Goravel ORM 新增模型关联,用 Golang 写关联也可以跟 Laravel 简单
韩同学的简单逻辑阅读 486
laravel 文档摘要
changsj阅读 460
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。