Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RuntimeException: Unable to create the cache directory (/var/www/sonata/app/cache/dev)

I installed the Sonata admin bundle.
After installation i refresh my page there is the cache problem then i use the following command to remove the cache:

rm -rf app/cache app/log 

Then I recreate the directory:

mkdir app/cache app/log 

But I got the following error:

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

like image 300
user2779489 Avatar asked Nov 21 '13 17:11

user2779489


1 Answers

It looks like a file/directory permission problem. The directory has to be writeable by the webserver. After creating the directory you should adjust the permissions with

chown -R www-data:www-data app/cache chown -R www-data:www-data app/log 

Or for Symfony 4+:

chown -R www-data:www-data var 

This only works on linux systems. The user and group depends on your distribution. On Debian and Ubuntu this should be www-data, on CentOS it's afaik apache.

Another solution would be not to delete the whole folders but only their contents via

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

But please be careful with this command.

like image 158
l-x Avatar answered Sep 20 '22 17:09

l-x