Skip to content

Instantly share code, notes, and snippets.

@brysonreece
Last active May 23, 2017 08:33
Show Gist options
  • Select an option

  • Save brysonreece/6f1fc4abaaec44769fd400fddd2f0b94 to your computer and use it in GitHub Desktop.

Select an option

Save brysonreece/6f1fc4abaaec44769fd400fddd2f0b94 to your computer and use it in GitHub Desktop.
Fixes file permissions for a Laravel instance
#!/bin/bash
if [ -z "$1" ]
then
echo ""
echo "No user supplied!"
echo "USAGE: ./Laravel-Permissions-Fix.sh user group directory"
echo ""
exit 1
fi
if [ -z "$2" ]
then
echo ""
echo "No group supplied!"
echo "USAGE: ./Laravel-Permissions-Fix.sh user group directory"
echo ""
exit 1
fi
if [ -z "$3" ]
then
echo ""
echo "No directory supplied!"
echo "USAGE: ./Laravel-Permissions-Fix.sh user group directory"
echo ""
exit 1
fi
sudo usermod -a -G $2 $1
sudo chown -R $1:$2 $3
sudo find $3 -type f -exec chmod 664 {} \;
sudo find $3 -type d -exec chmod 775 {} \;
cd $3
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
if [ $3 == "./" ]
then
sudo chmod +x $0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment