RuntimeException: Unable to create the cache direc

2019-03-10 20:10发布

i installed the sonata admin bundle. After installation i refresh my page there is the cache problem then i use

rm -rf app/cache app/log

for remove the cache.then i also create the director using the command

mkdir app/cache app/log

then i got the new problem like this

Runtime Exception : Unable to create the cache directory (/var/www/sonata/app/cache/dev). Please help .

10条回答
何必那么认真
2楼-- · 2019-03-10 20:38

I solved it changing user and group of folder var/cache and var/logs, then I cleaned cache:

sudo chown -R www-data:www-data var/logs
sudo chown -R www-data:www-data var/cache

sudo rm -rf var/logs/* var/cache/*
查看更多
beautiful°
3楼-- · 2019-03-10 20:41

Also check the path. In my case, I had

return dirname(__DIR__) . '../../../../var/cache/

instead of

return dirname(__DIR__) . '/../../../../var/cache/ (missing /)

查看更多
爱情/是我丢掉的垃圾
4楼-- · 2019-03-10 20:41

It is mostly the permission issue.

I have got resolved it on MAC using command: $ sudo chmod -R 777 <path/to/cache/directory>

You might try: $ sudo chmod -R 777 /var/www/sonata/app/cache

查看更多
啃猪蹄的小仙女
5楼-- · 2019-03-10 20:44

I found a similar problem when I was using the PHP symfony as the error picture. I found it after running command

php bin/console cache:clear

I solved it by removed everything inside the folder /app/var/cache

enter image description here

查看更多
登录 后发表回答