【问题标题】:Set Laravel storage permission to 777?将 Laravel 存储权限设置为 777?
【发布时间】:2021-02-08 20:19:18
【问题描述】:

由于某种原因,我不得不将我的 laravel 存储文件夹设置为 777。

我运行此命令 sudo chmod -R 775 storage/ 并且我的权限错误未解决,因此我通过运行此命令 sudo chmod -R 777 storage/ 将权限从 775 更改为 777

我的问题是 777 权限可能会导致我的 laravel 中的任何问题(禁止访问 || 安全性)还是可以?

【问题讨论】:

    标签: php laravel laravel-8 chmod


    【解决方案1】:

    这是我找到的最佳解决方案。

    第一步:chown 根目录:

    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 {} \;
    

    第 5 步:授予 Web 服务器读写存储和缓存的权限

    sudo chgrp -R www-data storage bootstrap/cache
    sudo chmod -R ug+rwx storage bootstrap/cache
    

    来源:https://vijayasankarn.wordpress.com/2017/02/04/securely-setting-file-permissions-for-laravel-framework/

    【讨论】:

    • 感谢您的回复,但我真的很想通过将 chmod 更改为 777 来了解我的项目是否会发生任何访问或安全威胁?
    • @pejmankheyri 正如您从博客中看到的,这是一个严重的安全问题。
    【解决方案2】:

    从项目的根目录运行以下命令:

        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/
    

    【讨论】:

    • 你能解释一下这是做什么的吗?
    猜你喜欢
    • 2015-06-04
    • 2014-02-10
    • 2021-07-17
    • 1970-01-01
    • 2020-11-18
    • 2013-12-09
    • 2019-01-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多