问题描述
出于某种原因,我不得不将我的 Laravel 存储文件夹设置为 777。
我运行此命令 sudo chmod -R 775 storage/
并且我的权限错误未解决,因此我通过运行此命令 sudo chmod -R 777 storage/
将权限从 775 更改为 777
我的问题是 777 权限可能会导致我的 Laravel 出现任何问题(禁止访问 || 安全性)?
解决方法
这是我找到的最佳解决方案。
第一步:chown 根目录:
sudo chown -R www-data:www-data /path/to/root
第 2 步:授予 FTP 用于上传和处理文件(用于使用任何 FTP 客户端):
sudo usermod -a -G www-data ubuntu
第 3 步:将文件权限设置为 644:
sudo find /path/to/root -type f -exec chmod 644 {} \;
第 4 步:将目录权限设置为 755:
sudo find /path/to/root -type d -exec chmod 755 {} \;
第 5 步:授予 Web 服务器读写存储和缓存的权限
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
,
从项目的根目录运行以下命令:
sudo chmod -R gu+w storage/
sudo chmod -R guo+w storage/
sudo chmod -R gu+w bootstrap/cache/
sudo chmod -R guo+w bootstrap/cache/