Assuming www-data
is the webserver user.
It's not needed but for the sake of shortening commands we will set the LARAVEL_ROOT
env variable to the root of our laravel app.
LARAVEL_ROOT=/path/to/your/laravel/root/directory
Change the ownership of our project folder.
sudo chown -R www-data:www-data $LARAVEL_ROOT
Give permission for the files and folder to the machine and webserver user.
sudo find $LARAVEL_ROOT -type f -exec chmod 644 {} \;
sudo find $LARAVEL_ROOT -type d -exec chmod 775 {} \;
Give the webserver the rights to read and write storage and bootstrap folders.
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache