Hello Everyone,
This is my first post and I have gone through everything before posting here. We have just spent the better part of a week getting Magento 2 installed and working.
Our setup is as follows:-
Nginx 1.10
PHP 7.06
Ubuntu 16.04
Currently we are adding all our products so currently our VPS only has 1GB RAM which will be upgraded once we move into production.
Our issue is that a random times when we save products or even move between pages we receive a page full of errors. I will post them below.....For security I have removed the URL of our website. As it is a permissions error we have tried everything. We have run find var vendor pub/static pub/media app/etc -type f -exec chmod g+w {} \; and also find var vendor pub/static pub/media app/etc -type d -exec chmod g+w {} \;
but still be receive errors. The one below is when we moved between the product page in the backend to the customer page. Can someone please point us to the correct command to get all the permissions correct.....In addition we have noticed that the folder owner for folders and files beyond the main web root is root:root and our web user should be www-data.... Should be change ALL folders and files beyond the webroot to the nginx user too? This may be related to the error below but I just dont want to bulk change permissions as it took us long enough to get this far.
Any help would be appreciated.
Here is the code
Warning: file_put_contents(/var/www/.com/html/var/cache//mage-tags/mage---7bd_EAV): failed to open stream: Permission denied in /var/www/mydirtyunderwear.com/html/lib/internal/Cm/Cache/Backend/File.php on line 661 #0 [internal function]: Magento\Framework\App\ErrorHandler->handler(2, 'file_put_conten...', '/var/www/mydirt...', 661, Array) #1 /var/www/.com/html/lib/internal/Cm/Cache/Backend/File.php(661): file_put_contents('/var/www/mydirt...', '7bd_EAV_ENTITY_...', 10) #2 /var/www/.com/html/lib/internal/Cm/Cache/Backend/File.php(174): Cm_Cache_Backend_File->_updateIdsTags(Array, Array, 'merge') #3 /var/www/.com/html/vendor/magento/zendframework1/library/Zend/Cache/Core.php(390): Cm_Cache_Backend_File->save('a:22:{i:0;s:10:...', '7bd_EAV_ENTITY_...', Array, NULL) #4 /var/www/.com/html/vendor/magento/framework/Cache/Core.php(74): Zend_Cache_Core->save('a:22:{i:0;s:10:...', '7bd_EAV_ENTITY_...', Array, NULL, 8) #5 /var/www/.com/html/vendor/magento/framework/Cache/Frontend/Adapter/Zend.php(47): Magento\Framework\Cache\Core->save('a:22:{i:0;s:10:...', 'EAV_ENTITY_ATTR...', Array, NULL) #6 /var/www/.com/html/vendor/magento/framework/Cache/Frontend/Decorator/Bare.php(75): Magento\Framework\Cache\Frontend\Adapter\Zend->save('a:22:{i:0;s:10:...', 'EAV_ENTITY_ATTR...', Array, NULL) #7 /var/www/.com/html/vendor/magento/framework/Cache/Frontend/Decorator/TagScope.php(49): Magento\Framework\Cache\Frontend\Decorator\Bare->save('a:22:{i:0;s:10:...', 'EAV_ENTITY_ATTR...', Array, NULL) #8 /var/www/.com/html/vendor/magento/framework/Cache/Frontend/Decorator/Bare.php(75): Magento\Framework\Cache\Frontend\Decorator\TagScope->save('a:22:{i:0;s:10:...', 'EAV_ENTITY_ATTR...', Array, NULL) #9 /var/www/.com/html/vendor/magento/framework/App/Cache.php(73): Magento\Framework\Cache\Frontend\Decorator\Bare->save('a:22:{i:0;s:10:...', 'EAV_ENTITY_ATTR...', Array, NULL) #10 /var/www/.com/html/vendor/magento/framework/App/Cache/Proxy.php(81): Magento\Framework\App\Cache->save('a:22:{i:0;s:10:...', 'EAV_ENTITY_ATTR...', Array, NULL) #11 /var/www/m.com/html/vendor/magento/module-eav/Model/Config.php(519): Magento\Framework\App\Cache\Proxy->save('a:22:{i:0;s:10:...', 'EAV_ENTITY_ATTR...', Array) #12 /var/www/com/html/vendor/magento/module-customer/Model/AttributeMetadataDataProvider.php(79): Magento\Eav\Model\Config->getEntityAttributeCodes(Object(Magento\Eav\Model\Entity\Type), Object(Magento\Framework\DataObject)) #13 /var/www/.com/html/vendor/magento/module-customer/Model/Metadata/CustomerMetadata.php(102): Magento\Customer\Model\AttributeMetadataDataProvider->getAllAttributeCodes('customer', 1) #14 /var/www/.com/html/vendor/magento/module-customer/Model/Metadata/CachedMetadata.php(94): Magento\Customer\Model\Metadata\CustomerMetadata->getAllAttributesMetadata() #15 /var/www/.com/html/vendor/magento/module-customer/Ui/Component/Listing/AttributeRepository.php(66): Magento\Customer\Model\Metadata\CachedMetadata->getAllAttributesMetadata() #16 /var/www/.com/html/vendor/magento/module-customer/Ui/Component/Listing/Columns.php(96): Magento\Customer\Ui\Component\Listing\AttributeRepository->getList() #17 /var/www/.com/html/vendor/magento/framework/View/Layout/Generator/UiComponent.php(148): Magento\Customer\Ui\Component\Listing\Columns->prepare() #18 /var/www/.com/html/vendor/magento/framework/View/Layout/Generator/UiComponent.php(145): Magento\Framework\View\Layout\Generator\UiComponent->prepareComponent(Object(Magento\Customer\Ui\Component\Listing\Columns)) #19 /var/www/com/html/vendor/magento/framework/View/Layout/Generator/UiComponent.php(126): Magento\Framework\View\Layout\Generator\UiComponent->prepareComponent(Object(Magento\Ui\Component\Listing)) #20 /var/www/.com/html/vendor/magento/framework/View/Layout/Generator/UiComponent.php(93): Magento\Framework\View\Layout\Generator\UiComponent->generateComponent(Object(Magento\Framework\View\Layout\Data\Structure), 'customer_listin...', Array, Object(Magento\Framework\View\Layout\Interceptor)) #21 /var/www/.com/html/vendor/magento/framework/View/Layout/GeneratorPool.php(86): Magento\Framework\View\Layout\Generator\UiComponent->process(Object(Magento\Framework\View\Layout\Reader\Context), Object(Magento\Framework\View\Layout\Generator\Context)) #22 /var/www/.com/html/vendor/magento/framework/View/Layout.php(327): Magento\Framework\View\Layout\GeneratorPool->process(Object(Magento\Framework\View\Layout\Reader\Context), Object(Magento\Framework\View\Layout\Generator\Context)) #23 /var/www/.com/html/var/generation/Magento/Framework/View/Layout/Interceptor.php(89): Magento\Framework\View\Layout->generateElements() #24 /var/www/.com/html/vendor/magento/framework/View/Layout/Builder.php(129): Magento\Framework\View\Layout\Interceptor->generateElements() #25 /var/www/com/html/vendor/magento/framework/View/Page/Builder.php(55): Magento\Framework\View\Layout\Builder->generateLayoutBlocks() #26 /var/www/.com/html/vendor/magento/framework/View/Layout/Builder.php(65): Magento\Framework\View\Page\Builder->generateLayoutBlocks() #27 /var/www/com/html/vendor/magento/framework/View/Layout.php(244): Magento\Framework\View\Layout\Builder->build() #28 /var/www/.com/html/vendor/magento/framework/View/Layout.php(859): Magento\Framework\View\Layout->build() #29 /var/www/com/html/var/generation/Magento/Framework/View/Layout/Interceptor.php(414): Magento\Framework\View\Layout->getBlock('menu') #30 /var/www/com/html/vendor/magento/module-backend/Model/View/Result/Page.php(59): Magento\Framework\View\Layout\Interceptor->getBlock('menu') #31 /var/www/.com/html/var/generation/Magento/Backend/Model/View/Result/Page/Interceptor.php(24): Magento\Backend\Model\View\Result\Page->setActiveMenu('Magento_Custome...') #32 /var/www/.com/html/vendor/magento/module-customer/Controller/Adminhtml/Index/Index.php(26): Magento\Backend\Model\View\Result\Page\Interceptor->setActiveMenu('Magento_Custome...') #33 /var/www/.com/html/var/generation/Magento/Customer/Controller/Adminhtml/Index/Index/Interceptor.php(24): Magento\Customer\Controller\Adminhtml\Index\Index->execute() #34 /var/www/.com/html/vendor/magento/framework/App/Action/Action.php(102): Magento\Customer\Controller\Adminhtml\Index\Index\Interceptor->execute() #35 /var/www/.com/html/vendor/magento/module-backend/App/AbstractAction.php(226): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http)) #36 [internal function]: Magento\Backend\App\AbstractAction->dispatch(Object(Magento\Framework\App\Request\Http)) #37 /var/www/com/html/vendor/magento/framework/Interception/Interceptor.php(74): call_user_func_array(Array, Array) #38 /var/www/.com/html/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Customer\Controller\Adminhtml\Index\Index\Interceptor->___callParent('dispatch', Array) #39 /var/www/.com/html/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Custome...', 'dispatch', Object(Magento\Customer\Controller\Adminhtml\Index\Index\Interceptor), Array, 'adminAuthentica...') #40 /var/www/.com/html/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(143): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http)) #41 [internal function]: Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch(Object(Magento\Customer\Controller\Adminhtml\Index\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http)) #42 /var/www/mydirtyunderwear.com/html/vendor/magento/framework/Interception/Chain/Chain.php(67): call_user_func_array(Array, Array) #43 /var/www/.com/html/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Custome...', 'dispatch', Object(Magento\Customer\Controller\Adminhtml\Index\Index\Interceptor), Array, 'designLoader') #44 /var/www/com/html/vendor/magento/framework/App/Action/Plugin/Design.php(39): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http)) #45 [internal function]: Magento\Framework\App\Action\Plugin\Design->aroundDispatch(Object(Magento\Customer\Controller\Adminhtml\Index\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http)) #46 /var/www/.com/html/vendor/magento/framework/Interception/Chain/Chain.php(67): call_user_func_array(Array, Array) #47 /var/www/.com/html/vendor/magento/framework/Interception/Interceptor.php(136): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Custome...', 'dispatch', Object(Magento\Customer\Controller\Adminhtml\Index\Index\Interceptor), Array, 'adminMassaction...') #48 /var/www/.com/html/vendor/magento/module-backend/App/Action/Plugin/MassactionKey.php(33): Magento\Customer\Controller\Adminhtml\Index\Index\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http)) #49 [internal function]: Magento\Backend\App\Action\Plugin\MassactionKey->aroundDispatch(Object(Magento\Customer\Controller\Adminhtml\Index\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http)) #50 /var/www/.com/html/vendor/magento/framework/Interception/Interceptor.php(140): call_user_func_array(Array, Array) #51 /var/www/.com/html/var/generation/Magento/Customer/Controller/Adminhtml/Index/Index/Interceptor.php(39): Magento\Customer\Controller\Adminhtml\Index\Index\Interceptor->___callPlugins('dispatch', Array, Array) #52 /var/www/m.com/html/vendor/magento/framework/App/FrontController.php(55): Magento\Customer\Controller\Adminhtml\Index\Index\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http)) #53 [internal function]: Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http)) #54 /var/www/.com/html/vendor/magento/framework/Interception/Interceptor.php(74): call_user_func_array(Array, Array) #55 /var/www/r.com/html/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array) #56 /var/www/com/html/vendor/magento/framework/Interception/Interceptor.php(136): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'install') #57 /var/www/.com/html/vendor/magento/framework/Module/Plugin/DbStatusValidator.php(69): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http)) #58 [internal function]: Magento\Framework\Module\Plugin\DbStatusValidator->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http)) #59 /var/www/.com/html/vendor/magento/framework/Interception/Interceptor.php(140): call_user_func_array(Array, Array) #60 /var/www/.com/html/var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array) #61 /var/www/com/html/vendor/magento/framework/App/Http.php(115): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http)) #62 /var/www/.com/html/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch() #63 /var/www/.com/html/pub/index.php(37): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http)) #64 {main}
I had the same error and my problem was that file permissions were incorrect.
To fix it, I ran this recursive command to ensure that the Apache service has read permissions.
"sudo chmod -R 755 ~/Sites"
It doesn't seem there is permission problem. Also I'm reporting it not during installation, I just trying to clear cache for already deployed project. Running php bin/magento cache:flush and have the same error
[Exception]
Warning: file_put_contents(/home/viacheslav/dev/projects/snarkteam/repka2/public_html/var/cache//mage-tags/mage---092_CONFIG): failed to open stream: Permission denied in /home/viacheslav/dev/projects/snarkteam/repka2/public_htm
l/vendor/colinmollenhour/cache-backend-file/File.php on line 663
The problem came after upgrading magento to v. 2.1.0
There is excess slash coming to Cm_Cache_Backend_File::_tagPath() in
vendor/colinmollenhour/cache-backend-file/File.php through $this->_options['cache_dir'] option. Then another DIRECTORY_SEPARATOR is being added to the path so we have wrong path /var/cache//mage-tags/mage---092_CONFIG)
Only physical removing cache folder helps but the problem comes again after page load.
Hello,
Navigate to the root directory and execute the following command:
1. sudo rm -rf var/di var/generation var/cache
2. sudo php bin/magento setup:di:compile
3. sudo chmod 777 -R var/
4. sudo php bin/magento cache:clean
Hope this will help you.
Now I understood that path was good. Thanks :-)
Glad to hear that its help for you. Please can you accept/appreciate our answer so that we can improve our answers.
I use developer mode.
1st case:
rm -rf var/page_cache/* var/cache/* var/di/* var/generation/* var/view_preprocessed/*
chmod -R 777 var
php bin/magento cache:flush
ls -la var/cache/mage-tags/
-rw-rw---- 1 viacheslav viacheslav 1 лип 13 16:58 mage---092_CONFIG
-rw-rw---- 1 viacheslav viacheslav 35 лип 13 16:58 mage---092_CONFIG_SCOPES
-rw-rw---- 1 viacheslav viacheslav 339 лип 13 16:58 mage---092_MAGE
When I load page in browser I have PHP error on my site page for 'mage-tags' folder files
2nd case:
rm -rf var/page_cache/* var/cache/* var/di/* var/generation/* var/view_preprocessed/*
chmod -R 777 var
Load homepage from browser
ls -la var/cache/mage-tags/
-rw-rw---- 1 www-data www-data 134 лип 13 17:01 mage---092_1COLUMN
-rw-rw---- 1 www-data www-data 51 лип 13 17:01 mage---092_BLOCK_HTML
-rw-rw---- 1 www-data www-data 99 лип 13 17:01 mage---092_CATALOG_CATEGORY
I can't run
php bin/magento cache:flush
because I have no permissions
------------------------------------------------------------------------------------------------------------------
despite of using
chown -R viacheslav:www-group var/
chmod -R ug+rws var/
Usually a have delegated owner/group for each nested folder/file. But now I always having files with changed permissions. And even 777 is losting the last '7' after cache files creating. I didn't have this problem before upgrade to magento 2. I can't figure out whether there is magento 2 problem or my system updates (Ubuntu 16.04, Apache2, php56-fpm)
Hello,
Have you tried with super user mode(root) or use sudo before linux command.
e.g sudo php bin/magento cache:clean
I was using php56, there was a lot of issue during installing a new module so upgraded to php7 its work quite well for me.
as you mention you are getting an php error please would you paste here your error after checking magento error log or server error log.
SUDO works for cleaning, of course.
But this is not enough for me to use this way :-)
When var/cache/mage-tags folder is empty, the page request fills this folder with files with
-rw-rw---- 1 www-data www-data 134 лип 13 18:38 mage---092_1COLUMN
permissions. As you see, there is no 777 as I made.
So, my user 'viacheslav' doesn't have permissions to remove files with www-data:www-data permissions. Only sudo helps.
Earlier, I could use command to delegate
viacheslav:www-group
permissions for each file which has been created:
chmod -R ug+rws var/
and created file was
-rw-rw---- 1 viacheslav:www-group 134 лип 13 18:38 mage---092_1COLUMN
and it worked for me. But today I have wrong user and owner for new created files. As result, I have to use SUDO