Created
August 29, 2023 06:23
-
-
Save fadlisaad/3a281b4d8a2e43e4068d43a3bf69cf10 to your computer and use it in GitHub Desktop.
Command to set Laravel permission Ubuntu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Default variables | |
groupname="${1:-www-data}" | |
username="${2:-$USER}" | |
folder="${3:-.}" | |
# Add user to webserver group | |
usermod -a -G "$groupname" "$username" | |
# Change storage ownership to normal user/ webserver group | |
chown -R "$username":"$groupname" "$folder"/storage | |
chmod 775 "$folder"/storage | |
# Update permissions for all storage files | |
find "$folder"/storage -type f -exec chmod 664 {} \; | |
# Update permissions for all storage folders | |
find "$folder"/storage -type d -exec chmod 775 {} \; | |
# Change owner group to webserver group user for storage and bootstrap cache folder | |
chgrp -R "$groupname" "$folder"/storage "$folder"/bootstrap/cache |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment