Skip to content

Instantly share code, notes, and snippets.

@webdevotion
Created January 9, 2015 09:49
Show Gist options
  • Save webdevotion/e9c04fab50ad0cae9748 to your computer and use it in GitHub Desktop.
Save webdevotion/e9c04fab50ad0cae9748 to your computer and use it in GitHub Desktop.
Fixing cache and logs permissions in Symfony application
# remove existing folders with unnecessary
ϟ sudo rm -rf app/cache/*
ϟ sudo rm -rf app/logs/*
# get the current apache user
ϟ HTTPDUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1`
ϟ echo $HTTPDUSER
# chmod the folders with the apache user and your current CLI user
ϟ sudo chmod +a "$HTTPDUSER allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
ϟ sudo chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
# run the same command on other ( custom ) folders that need the same permissions
ϟ sudo chmod +a "$HTTPDUSER allow delete,write,append,file_inherit,directory_inherit" web/logs/
ϟ sudo chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" web/logs/
# restart the server
ϟ sudo apachectl restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment