laravel change file permissions – 9

Change all file permissions to 644. Change all folder permissions to 755. For storage and open your codes files are running finally. i will provide with few step and follow and your problem has been solved.

The official doc says for laravel change file permissions:

laravel change file permissions - 9, laravel change file permissions, How to set up file permissions for Laravel?

IF Just to state the obvious for anyone viewing this discussion…. if you give any of your folders 777 permissions, you are allowing ANYONE to read, write and execute any file in that directory…. what this means is you have given ANYONE (any hacker or malicious person in the entire world) permission to upload ANY file, virus or any other file, and THEN execute that file…

IF YOU ARE SETTING YOUR FOLDER PERMISSIONS TO 777 YOU HAVE OPENED YOUR SERVER TO ANYONE THAT CAN FIND THAT DIRECTORY. Clear enough??? 🙂

Solution 2:

sudo chown -R www-data:www-data /var/www/html/laravel/root/directory

SET directory permissions:

sudo find /var/www/html/laravel -type d -exec chmod 755 {} \;

Your user as owner:

I prefer to own all the directories and files working easyer, so, go to your laravel root directory:

cd /var/www/html/laravel-code -->current root directory
sudo chown -R $USER:www-data .

Then I give both myself and the webserver permissions:

sudo find . -type f -exec chmod 664 {} \;   
sudo find . -type d -exec chmod 775 {} \;

Change the permissions for your project folder to enable read/write/exec for any user within the group owning the directory (which in your case is _www):

chmod -R 775 /var/www/html/laravel-code

This is what worked for me:

cd /code/laravel_project
php artisan cache:clear
php artisan config:clear
sudo service php7.4-fpm stop
sudo service nginx stop

sudo chown -R $USER:www-data /var/www/html/laravel-code/storage
sudo chown -R $USER:www-data /var/www/html/laravel-code
chmod -R 775 storage
chmod -R 755 /var/www/html/laravel-code
sudo service php7.4-fpm start && sudo service nginx start

Read Also:

1 thought on “laravel change file permissions – 9”

Leave a Comment