9

I am trying to get Magento 2 installed on my Centos7 LEMP-stack, but after a successful CLI-installation and setting the Magento on Developer-mode, I get the following message when trying to open the page:

1 exception(s):
Exception #0 (Exception): Warning: SessionHandler::read(): open(/var/lib/php/session/sess_c1qi0gaoj25njvfbt92lee4ao6, O_RDWR) failed: No such file or directory (2) in /var/www/magento2/vendor/magento/framework/Session/SaveHandler/Native.php on line 22

Exception #0 (Exception): Warning: SessionHandler::read(): open(/var/lib/php/session/sess_c1qi0gaoj25njvfbt92lee4ao6, O_RDWR) failed: No such file or directory (2) in /var/www/magento2/vendor/magento/framework/Session/SaveHandler/Native.php on line 22
#0 [internal function]: Magento\Framework\App\ErrorHandler->handler(2, 'SessionHandler:...', '/var/www/magent...', 22, Array)
#1 /var/www/magento2/vendor/magento/framework/Session/SaveHandler/Native.php(22): SessionHandler->read('c1qi0gaoj25njvf...')
#2 /var/www/magento2/vendor/magento/framework/Session/SaveHandler.php(93): Magento\Framework\Session\SaveHandler\Native->read('c1qi0gaoj25njvf...')
#3 [internal function]: Magento\Framework\Session\SaveHandler->read('c1qi0gaoj25njvf...')
#4 /var/www/magento2/vendor/magento/framework/Session/SessionManager.php(189): session_start()
#5 /var/www/magento2/vendor/magento/framework/Interception/Interceptor.php(146): Magento\Framework\Session\SessionManager->start()
#6 /var/www/magento2/var/generation/Magento/Framework/Session/Generic/Interceptor.php(52): Magento\Framework\Session\Generic\Interceptor->___callPlugins('start', Array, Array)
#7 /var/www/magento2/vendor/magento/framework/Session/SessionManager.php(130): Magento\Framework\Session\Generic\Interceptor->start()
#8 /var/www/magento2/var/generation/Magento/Framework/Session/Generic/Interceptor.php(14): Magento\Framework\Session\SessionManager->__construct(Object(Magento\Framework\App\Request\Http), Object(Magento\Framework\Session\SidResolver\Proxy), Object(Magento\Framework\Session\Config), Object(Magento\Framework\Session\SaveHandler), Object(Magento\Framework\Session\Validator), Object(Magento\Framework\Session\Storage), Object(Magento\Framework\Stdlib\Cookie\PhpCookieManager), Object(Magento\Framework\Stdlib\Cookie\CookieMetadataFactory), Object(Magento\Framework\App\State))
#9 /var/www/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(93): Magento\Framework\Session\Generic\Interceptor->__construct(Object(Magento\Framework\App\Request\Http), Object(Magento\Framework\Session\SidResolver\Proxy), Object(Magento\Framework\Session\Config), Object(Magento\Framework\Session\SaveHandler), Object(Magento\Framework\Session\Validator), Object(Magento\Framework\Session\Storage), Object(Magento\Framework\Stdlib\Cookie\PhpCookieManager), Object(Magento\Framework\Stdlib\Cookie\CookieMetadataFactory), Object(Magento\Framework\App\State))
#10 /var/www/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(89): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\\Framewo...', Array)
#11 /var/www/magento2/vendor/magento/framework/ObjectManager/ObjectManager.php(71): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Framewo...')
#12 /var/www/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(126): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Framewo...')
#13 /var/www/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(53): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, 'Magento\\Framewo...', NULL, 'session', 'Magento\\Store\\A...')
#14 /var/www/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(82): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments('Magento\\Store\\A...', Array, Array)
#15 /var/www/magento2/vendor/magento/framework/ObjectManager/ObjectManager.php(71): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Store\\A...')
#16 /var/www/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(126): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Store\\A...')
#17 /var/www/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(53): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, 'Magento\\Framewo...', NULL, 'redirect', 'Magento\\Framewo...')
#18 /var/www/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(82): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments('Magento\\Framewo...', Array, Array)
#19 /var/www/magento2/vendor/magento/framework/ObjectManager/ObjectManager.php(71): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Framewo...')
#20 /var/www/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(126): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Framewo...')
#21 /var/www/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(53): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, 'Magento\\Framewo...', NULL, 'context', 'Magento\\Cms\\Con...')
#22 /var/www/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(82): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments('Magento\\Cms\\Con...', Array, Array)
#23 /var/www/magento2/vendor/magento/framework/ObjectManager/ObjectManager.php(57): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Cms\\Con...', Array)
#24 /var/www/magento2/vendor/magento/framework/App/ActionFactory.php(40): Magento\Framework\ObjectManager\ObjectManager->create('Magento\\Cms\\Con...')
#25 /var/www/magento2/vendor/magento/framework/App/Router/Base.php(300): Magento\Framework\App\ActionFactory->create('Magento\\Cms\\Con...')
#26 /var/www/magento2/vendor/magento/framework/App/Router/Base.php(161): Magento\Framework\App\Router\Base->matchAction(Object(Magento\Framework\App\Request\Http), Array)
#27 /var/www/magento2/vendor/magento/framework/App/FrontController.php(50): Magento\Framework\App\Router\Base->match(Object(Magento\Framework\App\Request\Http))
#28 /var/www/magento2/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#29 /var/www/magento2/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#30 /var/www/magento2/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'requestPreproce...')
#31 /var/www/magento2/vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(94): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#32 /var/www/magento2/vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#33 /var/www/magento2/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'install')
#34 /var/www/magento2/vendor/magento/framework/Module/Plugin/DbStatusValidator.php(69): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#35 /var/www/magento2/vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Framework\Module\Plugin\DbStatusValidator->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#36 /var/www/magento2/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'front-controlle...')
#37 /var/www/magento2/vendor/magento/module-page-cache/Model/App/FrontController/VarnishPlugin.php(55): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#38 /var/www/magento2/vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\PageCache\Model\App\FrontController\VarnishPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#39 /var/www/magento2/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'front-controlle...')
#40 /var/www/magento2/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(73): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#41 /var/www/magento2/vendor/magento/framework/Interception/Interceptor.php(142): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#42 /var/www/magento2/var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
#43 /var/www/magento2/vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#44 /var/www/magento2/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
#45 /var/www/magento2/pub/index.php(37): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#46 {main}

So I go see those directories, and notice that the /var/www/magento2/var/lib/php/session" -path does not exist, but there is shorter "var/www/magento2/var/session" -path existing instead, and it has "sess_" -file inside of it.

Am I supposed to change some config -file to point into that directory instead? And if I am, where and what file would that be? Or is it something else completely?

EDIT: My local user has been added to webservers group and permissions are set as following:

chown -R myuser:webservergroup /var/www/magento2/
chmod -R 755 /var/www/magento2/
chmod -R 777 /var/www/magento2/var/
chmod -R 777 /var/www/magento2/pub/

My PHP.ini is currently set as following (orginally save_path was commented out):

session.save_handler = files
session.save_path = "var/www/magento2/var/session"

PHP.env didn't have 'save_path' directive so I added it:

  'session' =>
     array (
    'save' => 'files',
    'save_path' => '/var/session',
   ),

But still having the same issue.

6
  • 1
    I think your problem's related to permission. Please, check the user permission again. Commented Jul 12, 2016 at 3:31
  • 1
    Also see if you're setting a session directory in php.ini. That overrides Magento's default of var/session and might cause this issue. See this. Commented Jul 12, 2016 at 12:44
  • @KhoaTruongDinh I added some more information about my permissions and php.ini and php.env -files.
    – MyrkkyMies
    Commented Jul 12, 2016 at 14:35
  • You tried the way @SteveJohnson mentioned? Commented Jul 12, 2016 at 14:52
  • 1
    @KhoaTruongDinh Allright, I managed to get it work by editing 'save_path' -directive in php.env once more. I had to use complete path '/var/www/magento2/var/session', in order to get it work.
    – MyrkkyMies
    Commented Jul 12, 2016 at 15:59

4 Answers 4

10

So this solved this for me, thank you @Steve Johnson.

Edited php.ini file:

session.save_handler = files
;session.save_path = "/tmp"

-->

session.save_handler = files
session.save_path = "var/www/magento2/var/session"

Edited php.env file:

'session' =>
     array (
    'save' => 'files',
   ),

-->

'session' =>
     array (
    'save' => 'files',
    'save_path' => '/var/www/magento2/var/session',
   ),
5

Thank you so much this also helped me fix my problem...

I had used the free Softaculous Installer via my cPanel to install Magento v2.2.6 It said the installation was successful but when trying to access Magento I got the error "There has been an error processing your request".

I found the detailed error messages in the ./var/reports directory and they looked like this:

Warning: SessionHandler::read(): open(195.201.9.76:11211/sess_0622981ed0e8a3aaf857122afbd443a7, O_RDWR) failed: No such file or directory (2) in //public_html//vendor/magento/framework/Session/SaveHandler/Native.php on line 22

So my session directory was in a slightly different place from the above solution...I added a save_path entry into my ./app/etc/env.php file....in the session section like this:

'session' =>
     array (
    'save' => 'files',
    'save_path' => './vendor/magento/framework/Session'
   ),

And then it worked fine!

2
  • But it is not work
    – Jaisa
    Commented Feb 12, 2019 at 6:13
  • It worked for me :) Commented Sep 10, 2019 at 13:54
1

edit /app/etc/env.php file

'session' => [
    'save' => 'files',
    'save_path' => 'D:\wamp64\www\projectName\var\session' // put full directory path
],

it worked fine!

1

check app/etc/env.php

and remove line - SESSION save_path

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.