本文介绍了Symfony 2缓存清除问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Symfony 2网站最近在尝试清除缓存时出现问题。
我在终端中键入以下命令:

My Symfony 2 website has recently been giving me problems when I try to clear the cache.I type the following command in the terminal:

php app/console cache:clear --env=dev

并出现以下错误:

[ErrorException]
 Warning: rename(/var/www/corpsite/corpsite/app/cache/dev,/var/www/corpsite/corpsite/app/cache/dev_old): Directory not empty in /var/www/corpsite/corpsite/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php line 74

中不为空

所以我将该文件的权限更改为777,然后重新运行clear cache命令,这给了我这个错误:

So I change the permissions on that file to 777, and re-run the clear cache command, which gives me this error:

  [ErrorException]
  Warning: unlink(/var/www/corpsite/corpsite/app/cache/dev_old/twig/6b/e9/4491e41b895786689b86f32f446f.php): Permission denied in /var/www/corpsite/corpsite/vendor/symfony/src/Symfony/Component/HttpKernel/Util/Filesystem.php line 100

我可以解决这个问题通过删除'dev_old'文件夹,但我想解决引起该问题的问题。

I can get round the problem by deleting the 'dev_old' folder, but I want to solve the problem that is causing the issue.

PS-我知道该站点正在开发模式下运行。该网站已经存在了10个月,而且从来没有出现过任何问题。

P.S - I am aware the site is running in dev mode. The site has been live for 10 months and this has never been an issue before.

我们非常感谢您的帮助!

Any help is appreciated!

推荐答案

您需要同时拥有对缓存&日志文件夹。为此,您可以按照此处给出的指示进行操作:

You need to get your access rights on both cache & logs folders. To do that, you can follow the indications given here : http://symfony.com/doc/current/book/installation.html#configuration-and-setup

有几种方法,具体取决于您的操作系统(将www-data替换为apache用户):

There are several ways, depending on your OS (replace www-data with your apache user):

如果支持chmod + a:

If it supports chmod +a:

$ rm -rf app/cache/*
$ rm -rf app/logs/*

$ sudo chmod +a "www-data 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

否则,如果它支持setfacl(请参阅):

Else, if it supports setfacl (see https://help.ubuntu.com/community/FilePermissionsACLs):

$ sudo setfacl -R -m u:www-data:rwX -m u:`whoami`:rwX app/cache app/logs
$ sudo setfacl -dR -m u:www-data:rwx -m u:`whoami`:rwx app/cache app/logs

否则,将这些行放入应用程序/控制台,web / app.php&的开头web / app_dev.php(不推荐):

Else, put those lines in the beginning of app/console, web/app.php & web/app_dev.php (not recommended):

umask(0002); // This will let the permissions be 0775

// or

umask(0000); // This will let the permissions be 0777

这篇关于Symfony 2缓存清除问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 09:07