由于某种原因,我不得不将我的Laravel存储文件夹设置为777。
我运行了这个命令sudo chmod -R 775 storage/
,但我的权限错误没有解决,所以我通过运行这个命令将权限从775更改为777:sudo chmod -R 777 storage/
我的问题是,777权限会对我的Laravel造成任何问题(禁止访问或安全性),还是可以接受的?
这是我找到的最佳解决方案。
步骤1:更改根目录的所有者:
sudo chown -R www-data:www-data /path/to/root
步骤2:授权FTP上传和操作文件(用于使用任何FTP客户端):
sudo usermod -a -G www-data ubuntu
步骤三:将文件权限设置为644:
sudo find /path/to/root -type f -exec chmod 644 {} \;
步骤四:将目录权限设置为755:
sudo find /path/to/root -type d -exec chmod 755 {} \;
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
这篇文章介绍了如何在 Laravel 框架中安全地设置文件权限。
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/