Set Laravel storage permission to 777?

Viewed 7069

For some reason, I had to set my laravel storage folder to 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/

My question is that 777 permission can cause any problem (Forbidden access || Security) in my laravel or its ok?

3 Answers

Here is the best solution that I found.

Step 1: chown the root directory:

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):

sudo usermod -a -G www-data ubuntu

Step 3: Set file permission to 644:

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

Step 4: Set directory permission to 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

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/

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/

In short based on OP question is: Set permission to: 775 And make sure that active users added to the group (check with ls -alh command)

Related