I have noticed that from time to time my Magento installation shows 404 on all pages. Panic!
After doing some research I found out that running:
chown -R root:www-data . in the document folder solved the problem temporarily.
Until the next day and the problem is back.
I have since then been able to recreate the problem with that if I run:
php bin/magento setup:di:compile
it crashes and requires me to run the: chown -R root:www-data .
to fix the problem.
Why is this? Why do I always get these errors?
The error log shows problems with the cache folder:
`#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\Fronte" while reading response header from upstream, client: 172.68.182.104, server: _, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.kickacc.se" ^C`
-
Check this. It will be helpful for you. https://magento.stackexchange.com/questions/267292/after-every-setupupgrade-i-need-to-give-permission-debien/267334#267334Yash Shah– Yash Shah2019年04月20日 07:33:57 +00:00Commented Apr 20, 2019 at 7:33
-
Thanks, but I am using nginx, LEMP (PHP 7.2 and MariaDB). Do you have any suggestions for that setup?user3091199– user30911992019年04月20日 14:19:59 +00:00Commented Apr 20, 2019 at 14:19
2 Answers 2
Execute these commands as a root user
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 root ownership as sudo chown -R :<web server group> . after executing this.
Try once again and say if you are facing the issue. Please also share the var and generated ownership file permissions to analyze the cause of the issue.
So don't you have a Magento user other than the root user
-
Its running as chown root:www-data at the moment. Does that sound ok ?user3091199– user30911992019年04月20日 14:21:50 +00:00Commented Apr 20, 2019 at 14:21
-
So don't you have a user?If not create one following the document devdocs.magento.com/guides/v2.3/install-gde/prereq/…. Don't give 777 access to your magento files and folders as it is not recommendedRaj Mohan R– Raj Mohan R2019年04月20日 17:21:23 +00:00Commented Apr 20, 2019 at 17:21
-
1Thanks, I have now created a new user, added it to the www-data group and also changed the ownerships of the files. Sofar no crash and I am able to run the
php bin/magento setup:di:compilewithout problems.user3091199– user30911992019年04月27日 12:21:14 +00:00Commented Apr 27, 2019 at 12:21
There might be 2 case
1. Cache issue
rm -rf var/cache/ var/generation/ var/page_cache/ var/view_preprocessed/
rm -rf pub/static/frontend/ pub/static/adminhtml/ pub/static/_requirejs/
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
2. Permission Issue
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
find ./var -type d -exec chmod 777 {} \;
find ./pub/media -type d -exec chmod 777 {} \;
find ./pub/static -type d -exec chmod 777 {} \;
chmod 777 ./app/etc
chmod 644 ./app/etc/*.xml
-
thanks! this worked for awhile until it stoped working. in my case it seems to have been me that forgot to create a new user for magento specific.user3091199– user30911992019年04月27日 12:22:20 +00:00Commented Apr 27, 2019 at 12:22
Explore related questions
See similar questions with these tags.