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
And get the following error:
[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
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
I can get round the problem by deleting the 'dev_old' folder, but I want to solve the problem that is causing the issue.
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 :
in Symfony3 folders with cache moved from
app
tovar
, so the command will be: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
There are several ways, depending on your OS (replace www-data with your apache user):
If it supports chmod +a:
Else, if it supports setfacl (see https://help.ubuntu.com/community/FilePermissionsACLs):
Else, put those lines in the beginning of app/console, web/app.php & web/app_dev.php (not recommended):