Pejman Zeynalkheyri
Pejman Zeynalkheyri

Reputation: 4804

Set Laravel storage permission to 777?

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?

Upvotes: 3

Views: 18735

Answers (3)

bandungeuy
bandungeuy

Reputation: 512

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)

Upvotes: 0

jeremykenedy
jeremykenedy

Reputation: 4275

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/

Upvotes: 6

Elnur Ibrahim-zade
Elnur Ibrahim-zade

Reputation: 821

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/

Upvotes: 10

Related Questions