Laravel框架log权限的问题

发布时间 2023-11-10 09:06:57作者: `奔跑的蜗牛

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