简体   繁体   English

设置Laravel存储权限为777?

[英]Set Laravel storage permission to 777?

For some reason, I had to set my laravel storage folder to 777.出于某种原因,我不得不将我的 laravel 存储文件夹设置为 777。

I run this command sudo chmod -R 775 storage/ and my permission error not resolved so then I changed the permission from 775 to 777 by running this command sudo chmod -R 777 storage/我运行此命令sudo chmod -R 775 storage/并且我的权限错误未解决,因此我通过运行此命令将权限从 775 更改为 777 sudo chmod -R 777 storage/

My question is that 777 permission can cause any problem (Forbidden access || Security) in my laravel or its ok?我的问题是 777 权限可能会在我的 laravel 中导致任何问题(禁止访问 || 安全)或它可以吗?

Here is the best solution that I found.这是我找到的最佳解决方案。

Step 1: chown the root directory:第1步:chown根目录:

sudo chown -R www-data:www-data /path/to/root

Step 2: Grant FTP for uploading and working with files (for using any FTP client):第 2 步:授予 FTP 用于上传和处理文件(用于使用任何 FTP 客户端):

sudo usermod -a -G www-data ubuntu

Step 3: Set file permission to 644:第三步:设置文件权限为644:

sudo find /path/to/root -type f -exec chmod 644 {} \;

Step 4: Set directory permission to 755:第四步:设置目录权限为755:

sudo find /path/to/root -type d -exec chmod 755 {} \;

Step 5: Give rights for web server to read and write storage and cache步骤 5:授予 web 服务器读写存储和缓存的权限

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

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

From the project's root run the following commands:从项目的根目录运行以下命令:

    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/

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

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