I have installed Symfony 2.0.7 on Ubuntu 11.10. I have this problem:
I changed the permissions of the cache
e logs
directories using the following commands:
chmod 777 -R cache
chmod 777 -R logs
and all functions as I was expecting.
Then I made:
app/console cache:clear
Clearing the cache for the dev environment with debug true
permissions of cache/dev change to 755 and symfony cannot write in that:
RuntimeException: Failed to write cache file "/var/www/myapp/app/cache/dev/classes.php".
in /var/www/myapp/app/bootstrap.php.cache line 1079 at ClassCollectionLoader::writeCacheFile() in /var/www/myapp/app/bootstrap.php.cache line 1017 at ClassCollectionLoader::load() in /var/www/myapp/app/bootstrap.php.cache line 682 at Kernel->loadClassCache() in /var/www/myapp/web/app_dev.php line 23
How can I solve this apparent bug in Symfony 2?
See the Setting up Permissions sidenote in the Configuration and Setup section. Use the ACL approach with setfacl
.
e.g.
sudo setfacl -R -m u:apache:rwX -m u:`whoami`:rwX app/cache app/logs
sudo setfacl -dR -m u:apache:rwX -m u:`whoami`:rwX app/cache app/logs
(where apache
is your HTTPD user)
Well, I'm using setfacl
to avoid that issues but I still having problems.
I'm working on a standard user directory so this do not work for me:
APACHEUSER=`ps aux | grep -E '[a]pache|[h]ttpd' | grep -v root | head -1 | cut -d\ -f1`
sudo setfacl -R -m u:$APACHEUSER:rwX -m u:`whoami`:rwX app/cache app/logs
sudo setfacl -dR -m u:$APACHEUSER:rwX -m u:`whoami`:rwX app/cache app/logs
If you too, do this: (as privileged user if necessary of course )
sudo rm -rf app/cache app/logs
Then as NORMAL user create both directories and then apply the commands below as NORMAL user too (without sudo):
exit (from root if necessary)
mkdir app/cache app/logs
APACHEUSER=`ps aux | grep -E '[a]pache|[h]ttpd' | grep -v root | head -1 | cut -d\ -f1`
setfacl -R -m u:$APACHEUSER:rwX -m u:`whoami`:rwX app/cache app/logs
setfacl -dR -m u:$APACHEUSER:rwX -m u:`whoami`:rwX app/cache app/logs
Note: remember that there are two spaces between -d\
and -f1
Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With