Skip to content

Instantly share code, notes, and snippets.

@Frolki1-Dev
Created January 31, 2020 09:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Frolki1-Dev/2dc87b3ea1380e294b44846124f81145 to your computer and use it in GitHub Desktop.
Save Frolki1-Dev/2dc87b3ea1380e294b44846124f81145 to your computer and use it in GitHub Desktop.
Setup Laravel file and directory permission for deployment on production
#!/bin/bash
echo "Setup the permission for Laravel project."
echo "Laravel base directory is $1"
echo ""
echo "Set owner to www-data"
chown -R www-data:www-data $1
echo ""
echo "Set all files to 644"
find $1 -type f -exec chmod 644 {} \;
echo ""
echo "Set all direcotries to 755"
find $1 -type d -exec chmod 755 {} \;
echo ""
echo "Correct the permission for the cache"
chgrp -R www-data $1/storage $1/bootstrap/cache
chmod -R ug+rwx $1/storage $1/bootstrap/cache
echo ""
echo "Setup finished"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment