File permissions in a Laravel project

Giving the right permissions to the files in a Laravel project is important. This will not only restrict the unauthorized access but also make sure that you do not get the file permission errors. Many a times, inexperienced developers grant 777 permissions to all the folders in the Laravel project thereby compromising the security.

On Ubuntu (or similar) you can follow these steps.

 sudo find <laravel project folder> -type d -exec chmod 755 {} \;
 sudo find <laravel project folder> -type d -exec chmod ug+s {} \;
 sudo find <laravel project folder> -type f -exec chmod 644 {} \;
 sudo chown -R ubuntu:www-data <laravel project folder>




sudo chgrp -R www-data storage bootstrap/cache <Also add your custom list of folders under public folder that need access to be granted>

sudo chmod -R ug+rwx storage bootstrap/cache <Also add your custom list of folders under public folder that need access to be granted>



Once you execute the above commands, you should be all set.

2 thoughts on “File permissions in a Laravel project

Leave a Reply

Your email address will not be published. Required fields are marked *