问题
I've installed Symfony on Mac Os X and do:
chmod -R 777 app/cache app/log
Try do this:
php app/console cache:clear
And get back error:
[RuntimeException]
Unable to write in the "/Users/anton/Sites/local/Symfony/app/cache/dev" directory
Try to fix it! Thanks!
回答1:
If you are on Mac you can use ACL as it is explained here. From the project directory:
sudo chmod +a "_www 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
_www
in the first line is the name of which is running the web server
You have to change whoami
in the second line as it is you when you type php app/console cache:clear
. (usually the name of your home folder)
回答2:
Apparently your web server (apache?) already created some files or dirs in the cache folder (so they are owned be the web servers user, probably www-data). In this case a chmod isn't enough, you have to execute a chown -R anton app/cache app/log.
To avoid the general problem of different owners of different cache files, your console user and the user executing php for the web server should be the same. There are different ways to accomplish this. You could:
- Change your apache configuration, so the apache runs with your user (anton) rather than www-data
- Drop mod_php and use php5-fpm instead (and configure it to use your user)
- Use fast_cgi
来源:https://stackoverflow.com/questions/11702888/work-with-app-console-in-symfony-at-mac-os-x