Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 200
Pejman Kheyri Avatar asked Jan 26 '26 22:01

Pejman Kheyri


1 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/

like image 165
Elnur Ibrahim-zade Avatar answered Jan 28 '26 14:01

Elnur Ibrahim-zade