Skip to content

Instantly share code, notes, and snippets.

@jkanclerz
Last active November 9, 2016 09:24
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 jkanclerz/085a96d76d8202cd137f16da40c84631 to your computer and use it in GitHub Desktop.
Save jkanclerz/085a96d76d8202cd137f16da40c84631 to your computer and use it in GitHub Desktop.
Magento fix http user permission
#!/bin/bash
HTTPDUSER=`ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1`
dirs=('var' 'pub/media' 'pub/static')
function fix_permission {
sudo chmod -R +a "$HTTPDUSER allow delete,write,append,file_inherit,directory_inherit" $1
sudo chmod -R +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" $1
}
for dir in ${dirs[@]};
do
fix_permission ${dir}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment