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



PHP Snippet 1:

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

PHP Snippet 2:

$ sudo rm -rf var/cache/*
$ sudo rm -rf var/logs/* 

PHP Snippet 3:

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

PHP Snippet 4:

chown -R apache:apache app/cache

PHP Snippet 5:

chown -R apache:apache app/logs

PHP Snippet 6:

php bin/console cache:clear

PHP Snippet 7:

twig:
    cache:  false

PHP Snippet 8:

$ sudo chown -R _www:_www var/cache
$ sudo chown -R _www:_www var/logs

PHP Snippet 9:

$cfg['TempDir'] = 'tmp'

PHP Snippet 10:

$cfg['TempDir'] = '/usr/share/phpmyadmin/tmp'

PHP Snippet 11:

sudo chown -R $USER var/cache
sudo chown -R $USER var/logs