简体   繁体   English

Laravel日志写入权限被拒绝

[英]Laravel log write permission denied

I am facing permission issue with log writing in my laravel app. 我在laravel应用中写入日志时遇到权限问题。 We have daily logs so a new log file gets created every day. 我们每天都有日志,因此每天都会创建一个新的日志文件。 The project folder ownership is set to www-data . 项目文件夹的所有权设置为www-data And the logs are normally generated with www-data permission. 并且日志通常是在具有www-data许可的情况下生成的。 But sometimes the logs are created with root user and then if somewhere I try to write in log I get permission denied and application crashes. 但是有时日志是由root用户创建的,然后如果我尝试在某个地方写日志,则会被拒绝权限,并且应用程序崩溃。

-rw-r--r-- 1 www-data www-data 77016 Sep 12 05:00 laravel-2017-09-11.log
-rw-r--r-- 1 root     root      1240 Sep 12 10:30 laravel-2017-09-12.log

For example, yesterday's log was created by www-data but today it's under root . 例如,昨天的日志是由www-data创建的,而今天它是在root下的。 So I am getting crashes everytime. 所以我每次都崩溃。 If I delete the log or change the permission to 777 then it solves for a while until it pops up again. 如果删除日志或将权限更改为777那么它会解决一会儿,直到再次弹出。 I cannot replicate the issue and don't know why logs are being created under root user. 我无法复制该问题,也不知道为什么要在root用户下创建日志。 Any help would be appriciated. 任何帮助将被申请。 Thank you. 谢谢。

You can run your cron as www-data user. 您可以以www-data用户身份运行cron。

Ex: * * * * * www-data php /path/to/artisan schedule:run >> /dev/null 2>&1 例如: * * * * * www-data php /path/to/artisan schedule:run >> /dev/null 2>&1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM