Issue
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?
Solution
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
Answered By - Elnur Ibrahim-zade Answer Checked By - Pedro (WPSolving Volunteer)