Laravel框架log权限的问题

storage目录权限已经设置成777,每天首次访问都会报以下异常:

The stream or file "/var/www/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied

查看php-fpm.conf的运行用户是www-data

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
user = www-data
group = www-data

更改 storage 文件夹拥有者与 php-fpm.conf 运行用户一致,则问题解决

sudo chown -R www-data:www-data storage

修改后如果还有问题,可以配置一下日志权限试试

 

posted @ 2023-11-10 09:05  `奔跑的蜗牛  阅读(418)  评论(0编辑  收藏  举报