Laravel daily log 权限不是 www 用户的问题

问题:Laravel daily log生成的日志文件,用户属主和权限不对
现象:写入日志时提示:failed to open stream: Permission denied
原因:用 root 用户执行 php artisan 命令,导致 artisan 生成的日志文件,用户组是 root,导致 web 方式(用户属主:www)执行的代码无法去写入相应的日志文件
解决方案:
1、不用 root 用户执行 php artisan 命令,用 www 用户去执行。
sudo crontab -u www -e
2、把artisan和php-fpm产生的日志分隔开来
3、acl权限(经测试,对已存在的文件有效,新生成的文件无效)
setfacl -R -d -m user:www:rwx laravel/storage/logs/

setfacl -R -d -m group:www:rwx laravel/storage/logs/

扩展阅读:
Laravel daily log created with wrong permissions:https://stackoverflow.com/questions/27674597/laravel-daily-log-created-with-wrong-permissions
laravel 日志文件权限问题:https://segmentfault.com/q/1010000021437912
Laravel daily log 经常提示权限有问题?:https://learnku.com/laravel/t/4341/help-laravel-daily-log-often-prompt-permission-to-ask-for-a-problem-once-and-for-all
laravel框架的日志权限问题:https://blog.csdn.net/weixin_40104079/article/details/83418874
Laravel日志文件写入失败(permission denied):https://blog.csdn.net/chuoqin1916/article/details/100767646?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param

发表评论?

0 条评论。

发表评论

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据