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.

Suresh Kumar Neti has written 7 articles

Has over 26 years of experience in various roles in software industry. As the Founder and CEO of Neti Software Services, loves finding solutions to problems faced by the customers.

2 thoughts on “File permissions in a Laravel project

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>