简体   繁体   English

登录Laravel 5.1的文件权限

[英]File permission of Log in Laravel 5.1

I'm using Laravel 5.1, with Log set to be generated daily. 我正在使用Laravel 5.1,并且每天都要设置日志。

I'm heavily using Jobs. 我正在大量使用乔布斯。 Web server is Apache, so therefore PHP is executed as apache user, so at the end of the day, a new log file is generated by apache user and file permission is 0644 . Web服务器是Apache,因此PHP是作为apache用户执行的,所以最终,由apache用户生成了一个新的日志文件,文件许可权是0644 I've workers configured via Supervisor, which is being run by apache user. 我已经通过apache用户运行的Supervisor配置了工作程序。 (So far so good) (到现在为止还挺好)

Now for a random spike in Queue, I've a script setup to run more worker (Consumers of Queue). 现在,对于队列中的随机峰值,我有一个脚本设置可以运行更多的工作程序(“队列的消费者”)。 Problem I'm facing is since Log file is generated with 0644 permission, other users doesn't have write permission to file. 我面临的问题是,由于日志文件是使用0644权限生成的,因此其他用户没有对该文件的写权限。

Few solutions I can think of is - 我能想到的几种解决方案是-

  • Start worker from root user (can't do, as I don't have permissions) root用户启动worker(无法执行,因为我没有权限)
  • A cron to change file permission to 0646 at 00:00:00 each day (also requires root) 每天在00:00:00将文件权限更改为0646 Cron(也需要root)
  • Generate Log file manually at 00:00:00 by current user, so that I would have authority to change permission to 0646 (Can't be reliable, what if apache creates it first) 当前用户在00:00:00手动生成日志文件,以便我有权将权限更改为0646 (这不可靠,如果apache首先创建它,该怎么办)
  • Start the worker as apache user (Since no root, so this is not possible) apache用户身份启动工作程序(因为没有root用户,所以这是不可能的)
  • This Question on Unix SE Site Unix SE网站上的此问题

So my question is what is the best way to do it, it looks like a general problem to me, which any developer could face. 所以我的问题是最好的方法是什么,这对我来说似乎是一个普遍的问题,任何开发人员都可能面对。 Or is there any better way to do this apart from above mentioned methods. 还是除了上述方法之外,还有其他更好的方法可以做到这一点。

[..] other users doesn't have write permission to file. [..]其他用户没有文件写入权限。

Are you sure you want those users to access the file directly? 您确定要让这些用户直接访问文件吗? You could just add an API to your laravel app to serve this file (or even only some filtered data from it). 您可以只向您的laravel应用程序添加一个API来提供此文件(或什至只是其中的一些过滤数据)。 This also allows you too have more fine grained access control within your app etc. 这也使您也可以在应用程序等中拥有更精细的访问控制。

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

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