After installation of Laravel you will require to configure some folder permissions. Currently till Laravel version 5.2 we require to set the permission of 2 folders.
- storage
- bootstrap/cache
These both folder need writable permission. Because we write the logs in storage folder and save cache in bootstrap/cache folder. Most of the developers set permission 777 to these folders.
Never ever set permission 777 to the folders until it is required. If you are giving 777 permission you are allowing anyone to Read, Write and Execute the files. If you are giving writable and executable permission then it's big security concern.
Now question is what permission should I set to these folders and here is the answer:
Go to terminal and then to you project directory after that run the below commands:
1
2
|
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
|
These two commands will set the writable permission to these folders but user will not be able to execute the code.
Rest of the directories require 755 permission and you can set 755 permission to all the folders with the below command:
1
|
find /var/www/html/laravel-project -type d -exec chmod 755 {} \;
|
I used in this command a character 'd' which denotes that I'm giving permission to directories. We also can set the permission to all the files by running below command:
1
|
find /var/www/html/laravel-project -type f -exec chmod 644 {} \;
|
Here in this command I have used a character 'f' which denotes that I'm giving permission to the files.