I am facing an issue after cloning my project from bitbucket repo on a different server that is having Centos 7.

Fatal error: Uncaught Zend_Cache_Exception: cache_dir "/var/www/html/var/page_cache" is not writable in /var/www/html/vendor/magento/zendframework1/library/Zend/Cache.php:209 Stack trace: #0 /var/www/html/vendor/magento/zendframework1/library/Zend/Cache/Backend/File.php(180): Zend_Cache::throwException('cache_dir "/var...') #1 /var/www/html/vendor/colinmollenhour/cache-backend-file/File.php(87): Zend_Cache_Backend_File->setCacheDir('/var/www/html/v...') #2 /var/www/html/vendor/magento/zendframework1/library/Zend/Cache.php(153): Cm_Cache_Backend_File->__construct(Array) #3 /var/www/html/vendor/magento/zendframework1/library/Zend/Cache.php(94): Zend_Cache::_makeBackend('Cm_Cache_Backen...', Array, true, true) #4 /var/www/html/vendor/magento/framework/App/Cache/Frontend/Factory.php(156): Zend_Cache::factory('Magento\Framewo...', 'Cm_Cache_Backen...', Array, Array, true, true, true) #5 /var/www/html/vendor/magento/framework/Cache/Frontend/Adapter/Zend.php(38): Magento\Framework\App\Cache\Frontend\Factory->Magento\Framework\A in /var/www/html/vendor/magento/zendframework1/library/Zend/Cache.php on line 209

I have given chmod 777 var/ -R and chmod 777 var/cache_dir/ -R .

But the error was same.

  • did u tried chmod -R 777 pub/ var/ generated/ ?
    – mohith
    Jun 12, 2019 at 9:33

2 Answers 2


You can fix it by following ways..

chmod 777 -R var/ generated/(root access if don't have root access try with sudo)

NP: you need to give permission every time when you use below cmd.

php bin/magento cache:flash

So, you need to give proper permission of your application . you can follow below links.

Check this link


Execute these commands as a root user. If you have already given 777 permission revert it using the first two commands else proceed with the rest.

find . -type f -exec chmod 664 {} \;

find . -type d -exec chmod 775 {} \;

find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +

find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +

Set the ownership to Magento user and web user using

sudo chown -R <Magento user>:<web server group> .

Running these commands sets the permission for folders and files in Magento root and for the new files to be created in var, pub, and generated directories.

Don't run any command as root user as it might cause the new static files to be created with root ownership which might prevent web user to access such files forcing you to provide 777 permission. Please at any case don't give 777 permission if so please revert it back. So run Magento commands as Magento user.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.