在日志文件中写入时Laravel

在日志文件中写入时Laravel

本文介绍了在日志文件中写入时Laravel 5权限被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我具有Ubuntu和Laravel 5框架,并且在浏览器中看到白屏.
当我更改storage/logs目录权限时,它会有所帮助,但由于每日"日志配置,我每天都必须这样做.

I have Ubuntu and Laravel 5 framework and I see the white screen in the browser.
When I change storage/logs directory permissions it helps, but I have to do it every day, due the 'daily' log configuration.

推荐答案

出于明显的安全原因,storagevendor文件夹的权限应保留在775.

The permissions for the storage and vendor folders should stay at 775, for obvious security reasons.

但是,您的计算机和服务器Apache都必须能够在这些文件夹中进行写入.例如:当您运行php artisan之类的命令时,您的计算机需要写入storage中的日志文件.

However, both your computer and your server Apache need to be able to write in these folders. Ex: when you run commands like php artisan, your computer needs to write in the logs file in storage.

您需要做的就是将文件夹的所有权授予Apache:

All you need to do is to give ownership of the folders to Apache :

sudo chown www-data:www-data /path/to/your/project/vendor
sudo chown www-data:www-data /path/to/your/project/storage

然后,您需要将计算机(由username引用)添加到服务器Apache所属的组中.像这样:

Then you need to add your computer (referenced by it's username) to the group to which the server Apache belongs. Like so :

sudo usermod -a -G www-data userName

groupName通常是www-data,但您可能希望将其替换为正确的组.

Most frequently, groupName is www-data but you might want to replace it with your correct group.

这篇关于在日志文件中写入时Laravel 5权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 01:34