After installing magento 2.3.5-p1 I get an exception on setup page (in web setup).

PHP Fatal error: Uncaught Zend_Cache_Exception: cache_dir "/var/www/html/magento2/var/page_cache" is not writable in /var/www/html/magento2/vendor/magento/zendframework1/library/Zend/Cache.php:209
Stack trace:
#0 /var/www/html/magento2/vendor/magento/zendframework1/library/Zend/Cache/Backend/File.php(180): Zend_Cache::throwException('cache_dir "/var...')
#1 /var/www/html/magento2/vendor/colinmollenhour/cache-backend-file/File.php(87): Zend_Cache_Backend_File->setCacheDir('/var/www/html/m...')
#2 /var/www/html/magento2/vendor/magento/zendframework1/library/Zend/Cache.php(153): Cm_Cache_Backend_File->__construct(Array)
#3 /var/www/html/magento2/vendor/magento/zendframework1/library/Zend/Cache.php(94): Zend_Cache::_makeBackend('Cm_Cache_Backen...', Array, true, true)
#4 /var/www/html/magento2/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/magento2/vendor/magento/framework/Cache/Frontend/Adapter/Zend.ph in /var/www/html/magento2/vendor/magento/zendframework1/library/Zend/Cache.php on line 209

But I set permissions like in Magento documentation. Only help to set 777 to var/ generated/ app/ and pub/ but it's not right way. Because after all this Magento install correct but when I try to run setup:upgrade afterwards, I lose my permissions and get the same error again.

2 Answers 2


Please make sure that you check your permissions and webserver user before running bin/magento setup:upgrade.

  • chown -R webusername:webusergroup /path/to/root/
  • Then you run the permissions that you tried, specifically 777.
  • But you need to run bin/magento setup:upgrade from the webusername not as root user. (If you run it as any other user as webusername then the ownership changes as well)

I have recently installed a Magento instance in Digitlal Ocean droplet(Ubuntu 16.04)by using the following command.This is mostly file ownership problem as well. Check the file owner is in the Apache group. Go to your Magento installed directory.

find var vendor pub/static pub/media app/etc -type f -exec chmod g+w {} \;
find var vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} \;
chown -R : .
chmod u+x bin/magento

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.