Magento 2 Installation Error: Page_Cache is Not Writable

error logfile-permissionsmagento2permissions

I'm trying to deploy magento 2.1.3 installed with composer on a CentOS 7 machine with apache 2.4 and it returns the error:

[Mon Jul 03 17:15:55.678068 2017] [:error] [pid 16315] [client 211.159.221.63:61183] PHP 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\nStack trace:\n#0 /var/www/html/vendor/magento/zendframework1/library/Zend/Cache/Backend/File.php(180): Zend_Cache::throwException('cache_dir "/var...')\n#1 /var/www/html/vendor/colinmollenhour/cache-backend-file/File.php(87): Zend_Cache_Backend_File->setCacheDir('/var/www/html/v...')\n#2 /var/www/html/vendor/magento/zendframework1/library/Zend/Cache.php(153): Cm_Cache_Backend_File->__construct(Array)\n#3 /var/www/html/vendor/magento/zendframework1/library/Zend/Cache.php(94): Zend_Cache::_makeBackend('Cm_Cache_Backen...', Array, true, true)\n#4 /var/www/html/vendor/magento/framework/App/Cache/Frontend/Factory.php(155): Zend_Cache::factory('Magento\\\\Framewo...', 'Cm_Cache_Backen...', Array, Array, true, true, true)\n#5 /var/www/html/vendor/magento/framework/App/Cache/Frontend/Pool.php(67): Magento\\Framework\\App\\Cache\\Frontend\\Factory->create(Array)\n#6 /var/w in /var/www/html/vendor/magento/zendframework1/library/Zend/Cache.php on line 209

// * (ip and port modified)

I tryed to give the propper permissions to the folders with the commands:

sudo chown -R apache:apache /var/www/html/
// or
sudo chmod -R 775 /var/www/html/

But none of them worked, I even tried with sudo chmod -R 777 /var/www/html/ with same result.

I found this post: Install issue permission and htaccess
and tried the solution proposed there:

<VirtualHost *:80>
DocumentRoot "/var/www/html"
ServerName www.example.com:80
<Directory /var/www/html>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

And same permissions error is there.

I can't get to work this magento 2, I always get the permissions error, even granting all the folders with 777 permission.

What am I doing wrong?

Edit: I tried umask with no result. I created the file magento_umask in <your Magento install dir>/magento_umask and placed inside 007, I also tried with `022. But still no luck.

I tryed giving permissions to apache group, and even adding the user with permissions to the apache group, but nothing worked.

Finally I've found somebody talking about SELinux modifying the permissions automatically, so I disabled the SELinux, and the everything worked.

Best Answer

Had the same issue with var/page_cache not writable. OP's answer pointed me in the right direction.

Rather than disabling SELinux completely, need to update SELinux security context for following directories:

chcon -R --type httpd_sys_rw_content_t <your Magento install dir>/app/etc
chcon -R --type httpd_sys_rw_content_t <your Magento install dir>/var
chcon -R --type httpd_sys_rw_content_t <your Magento install dir>/pub/media
chcon -R --type httpd_sys_rw_content_t <your Magento install dir>/pub/static

As described in Magento docs here https://devdocs.magento.com/guides/v2.2/install-gde/prereq/security.html

Related Topic