Work with app/console in Symfony at Mac OS X

孤者浪人 提交于 2019-12-06 10:44:30

问题


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:

  1. Change your apache configuration, so the apache runs with your user (anton) rather than www-data
  2. Drop mod_php and use php5-fpm instead (and configure it to use your user)
  3. Use fast_cgi


来源:https://stackoverflow.com/questions/11702888/work-with-app-console-in-symfony-at-mac-os-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!