The question:
Magento 2 below the Warning
come.
Warning: file_put_contents(/var/www/html/var/cache//mage-tags/mage---792_CONFIG):
failed to open stream: Permission denied in /var/www/html/vendor/colinmollenhour/cache-backend-file/File.php on line 663
Please Help.
After changing permissions I got an error “Class MagentoReviewModelReviewFactory does not exist”
Ok, I fixed above error by deleting generation folder and making static content deploy
The Solutions:
Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.
Method 1
Magento told you that you don’t have permissions to write in /var/cache folder, please check what are the permission of the /var folder.
Overview of ownership and permissions Magento 2
Method 2
I tried with sudo bin/magento setup:di:compile
and works fine.
Method 3
You can try changing all permissions by using the following command
sudo find . -type d -exec chmod 755 {} ;
sudo find . -type f -exec chmod 644 {} ;
I know it’s not the prettiest solutions, but it worked for me.
Method 4
you have a permission problem
Fix it by using this cmd : chmod 755 -R var/*
Method 5
I think it’s not a bug, I experienced the same after running the cache: clean command as root user.
So by applying for 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/sudo user
Method 6
For anyone that has recently had this problem.
I fixed this in my staging environment by running the chmod 755 -R var/* command, but make sure you do it to the /var directory and not /var/www/html/var. Hope it makes sense. I am quiet new to Linux so it took a while for me to get my head around.
This is also a very important reard https://devdocs.magento.com/guides/v2.3/install-gde/prereq/file-sys-perms-over.html
Method 7
The below fixed my problem, and magento runs very smooth ever.
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 {} +
//Change the ownership to your Magento user
sudo chown -R <Magento user>:<web server group> .
//<web server group> usually will be www-data
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0