Magento – Magento 2 : Permission denied with colinmollenhour module cache

file-permissionsmagento2.2

I regularly get this error message:

1 exception(s): Exception #0 (Exception): Warning:
file_put_contents(/var/www/html/magento/var/cache//mage-tags/mage—365_COMPILED_CONFIG):
failed to open stream: Permission denied in
/var/www/html/magento/vendor/colinmollenhour/cache-backend-file/File.php
on line 663

To fix it, I remove the cache :

rm -rf var/cache/* var/di/* var/generation/* var/page_cache/* var/view_preprocessed/* pub/static/frontend/*

But it always comes back regularly, although I've set the permissions for two users in development mode :

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

Even after cleaning the cache this way :

rm -rf var/cache/* var/di/* var/generation/* var/page_cache/* var/view_preprocessed/* pub/static/frontend/*
php bin/magento cache:clean
php bin/magento setup:upgrade
php bin/magento setup:di:compile

Is it a bug with Magento 2.2 or did I miss something ?

Best Answer

I think its not a bug, I experienced the same after running the cache:clean command as root user.

So by applying the file permission again this issue has been fixed. http://devdocs.magento.com/guides/v2.2/install-gde/prereq/file-sys-perms-over.html

So be careful don't clean the cache as root user.

Related Topic