Symfony 2.0 中缓存和日志文件夹中的权限问题 [英] Permission issue in cache and logs folder in Symfony 2.0

查看:38
本文介绍了Symfony 2.0 中缓存和日志文件夹中的权限问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了一些方法来授予 cache 权限 &logs 文件夹,但每当我清除缓存时,就会出现无法写入目录的问题.

I have tried some ways to give permission to the cache & logs folder but whenever I clear cache at that time the problem occurs like unable to write in directory.

我已经尝试过这两种方式:

I have tried this two ways:

  1. 通过具有 777 权限的 root 用户完全访问缓存.
  2. 像 Symfony2 文档中所说的 www-data 一样更改所有者.
  1. Full access to cache via the root user with 777 permissions.
  2. Change the owner like www-data as said in Symfony2 docs.

但它对我不起作用.

推荐答案

解决方案:

如果站点是面向全球的,那么如果您关心安全性,请不要禁用 SELinux.在这种情况下,您可能想要使用"SELinux,而不是禁用它,这是有原因的.

Solution:

Don't disable SELinux if you care about security if the site is global facing in anyway. In this case you would want to "Use" SELinux, not disable it, it's there for a reason.

我这样做;

# chcon -R -t httpd_sys_script_rw_t /var/www/symfonyapp/app/cache
# chcon -R -t httpd_sys_script_rw_t /var/www/symfonyapp/app/logs
# apachectl restart #(or systemctl restart httpd) or (service restart httpd) to restart your server, a reboot will suffice as well.

是的,@Viataley 有一个优点,现在您需要检查以确保您的网络服务器用户 httpdapachewwwdata 被添加到您的用户组,无论您的用户在哪个组.这样,当 apache 写入您的用户已通过资产重新编译的 symfony 目录时,当您为例如 g 运行缓存清除时ugo 的一部分是您的用户组,将允许 apache 用户对这些目录内容的权限.

And yes, @Viataley has one good point, now you need to check to make sure your web server user httpd, apache, or wwwdata is added to your users group, whatever group your user is in. This way when apache writes to the symfony directories that you user has recompiled through assetic when you run a cache clear for e.g., the g portion of the ugo which is your users group, will allow apache user permission to those dirs contents.

这篇关于Symfony 2.0 中缓存和日志文件夹中的权限问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆