#!/bin/bash set -e function perms-laravel { [[ -z $1 ]] && echo function perms-laravel needs vhost && exit 1 vhost=$1 echo $vhost/ chown -R runner. $vhost/ mkdir -p $vhost/bootstrap/cache/ mkdir -p $vhost/storage/{app,framework,logs}/ mkdir -p $vhost/storage/framework/{sessions,views,cache}/ chown -R www-data. $vhost/bootstrap/cache/ chown -R www-data. $vhost/storage/ # allow runner as part of the nginx/www-data group to write there with composer find $vhost/bootstrap/cache/ -type d -exec chmod 775 {} \; find $vhost/bootstrap/cache/ -type f -exec chmod 664 {} \; find $vhost/storage/ -type d -exec chmod 775 {} \; find $vhost/storage/ -type f -exec chmod 664 {} \; unset vhost } # assuming default nginx user on debian usermod -aG www-data runner # define your vhost folder here perms-laravel validate-laravel echo all done