douqinlu4217 2015-01-19 02:56
浏览 86

为Symfony2设置权限时出错

I am trying to setup Symfony2 on my Vagrant virtual machine.

When navigating to BASE_RULE/web/app_dev.php, this is the permission error I am receiving:

RuntimeException: Failed to write cache file "/var/www/app/cache/dev/classes.php".

Reading various StackOverflow threads and trying many different proposed solutions, people recommended me to use this Symfony2 Permissions article.

I have tried number 2, but since my system does not support chmod +a, I moved onto number 3:

HTTPDUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\  -f1`
sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs
sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs

When I execute the setfacl commands, here are the following errors:

vagrant@order-online:/var/www/app$ sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX cache logs
setfacl: cache: Operation not supported
setfacl: cache/.DS_Store: Operation not supported
setfacl: cache/dev: Operation not supported
setfacl: cache/dev/annotations: Operation not supported
setfacl: cache/dev/appDevDebugProjectContainer.php: Operation not supported
setfacl: cache/dev/appDevDebugProjectContainer.php.meta: Operation not supported
setfacl: cache/dev/appDevDebugProjectContainer.xml: Operation not supported
setfacl: cache/dev/appDevDebugProjectContainerCompiler.log: Operation not supported

So this one didn't work (or I am missing something..), so I moved onto number 4, which is setting umask(0000); under app/console, web/app.php and web/app_dev.php.

After applying that change in those three file locations, I cleared my cache, restarted Vagrant and Apache, but still received the same errors.

Thanks.

  • 写回答

2条回答 默认 最新

  • doupo2633 2015-01-19 04:00
    关注

    It could also be your group permissions. Check what user your webserver is using. If you're using nginx, you can usually find this in /etc/nginx/pool.d/www.conf. It's usually something like www-data. So you'd do: $ sudo chown -R www-data:www-data /var/www/your-symfony-project

    评论
  • dpr26232 2018-04-16 17:45
    关注

    I think you just need to change the cache and log permissions to be editable by the www-data and other groups. So just do this chmod -R 777 app/cache/* app/logs/*

    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部