Blog coding and discussion of coding about JavaScript, PHP, CGI, general web building etc.

Tuesday, December 29, 2015

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

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

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 .  

Answer by l-x for RuntimeException: Unable to create the cache directory (/var/www/sonata/app/cache/dev)


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

and

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

on the command line.

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.

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


And for centos:

chown -R apache:apache app/cache  

if you're coming here for Symfony Help you might have to do this as well if you delete the entire app/logs folder

chown -R apache:apache app/logs  

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


Changing the CHMOD might help but in case the cache annoys you during the deveopment you can just deactivate it. Navigate to your app config file (located in ../app/config/config.yml from your root directory). Scroll to the twig configuration settings (under twig:) and change the cache value (which should be pointing to the cache directory) to false like so:

twig:      cache:  false  

If you do not see any cache configuration entry, simply add the line above.

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


What is likely happening is that you are trying to create the file under apache/nginx. By default apache or nginx has umask set to 0022.

From: http://www.cyberciti.biz/tips/understanding-linux-unix-umask-value-usage.html

Explain Octal umask Mode 022 And 002

As I said earlier, if the default settings are not changed, files are created with the access mode 666 and directories with 777. In this example:

The default umask 002 used for normal user. With this mask default directory permissions are 775 and default file permissions are 664. The default umask for the root user is 022 result into default directory permissions are 755 and default file permissions are 644. For directories, the base permissions are (rwxrwxrwx) 0777 and for files they are 0666 (rw-rw-rw).

You will need to manually set the umask to 0002, and reset it back to its previous setting before you can create the directories.

Answer by Jirson Tavera for RuntimeException: Unable to create the cache directory (/var/www/sonata/app/cache/dev)


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/*  


Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72

0 comments:

Post a Comment

Popular Posts

Powered by Blogger.