Symfony2 Auto ACL / permissions bash script
Recently I had to install Symfony2 from scratch. Being a company that works on one install for years, we don’t always get acquainted with the install phase that often.
Every time I do a personal install just to screw around I have to go read how to do the ACL / Permissions for the cache and logs folders in /app/*
I decided a quick shell script to keep in my toolbox would be a good use of my time this evening. Here it is:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
#!/bin/bash USER=$(whoami) APACHE_USER=$(ps axho user,comm|grep -E "[h]ttpd|[a]pache"|uniq|grep -v "root"|awk 'END {print $1}') rm -rf app/cache/* rm -rf app/logs/* sudo chmod +a "$APACHE_USER allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs sudo chmod +a "$USER allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs php app/console cache:clear echo "You're good to go... load localhost/web/config.php" |
This quick script just follows a few steps that is done by the documentation at the Symfony2 Installation Documentation
- Copy this code into a file called “set_permissions.sh” in your project root.
- Add executable permission to the script, by running chmod +x set_permissions.sh
- Run the script:
./set_permissions.sh - If you’d like, delete the script afterward, alternatively you can keep it for when you do an update to your code / mess up your permissions (like I do from time to time 🙂 )
Have fun, hope it’s useful.
Grateful to Matthias Noback for his post on How to Install Sismo which is what gave me the idea of creating the shell script.