1

I installed Magento 2.1 on my Centos 7 server, running Nginx 1.10.1, MariaDB 10.1 and PHP7 with SSL. In theory, everything installed just fine and after the installation I got no errors what-so-ever, and "systemctl status nginx" and "systemctl status php-fpm" both show that they should be working fine. But when I try to access my site in web browser, I get following:

"There has been an error processing your request

Exception printing is disabled by default for security reasons.

Error log record number: 886472238215"

So I went to "usr/share/nginx/magento2/var/report" and opened that log number 886472238215:

a:4:{i:0;s:226:"Warning: SessionHandler::read(): open(/var/lib/php/session/sess_au56sith2u5dloibaakd9c3q06, O_RDWR) failed: Permission denied (13) in /usr/share/nginx/magento2/vendor/magento/framework/Session/SaveHandler/Native.php on line 22";i:1;s:6680:"#0 [internal function]: Magento\Framework\App\ErrorHandler->handler(2, 'SessionHandler:...', '/usr/share/ngin...', 22, Array)
#1 /usr/share/nginx/magento2/vendor/magento/framework/Session/SaveHandler/Native.php(22): SessionHandler->read('au56sith2u5dloi...')
#2 /usr/share/nginx/magento2/vendor/magento/framework/Session/SaveHandler.php(93): Magento\Framework\Session\SaveHandler\Native->read('au56sith2u5dloi...')
#3 [internal function]: Magento\Framework\Session\SaveHandler->read('au56sith2u5dloi...')
#4 /usr/share/nginx/magento2/vendor/magento/framework/Session/SessionManager.php(189): session_start()
#5 /usr/share/nginx/magento2/vendor/magento/framework/Interception/Interceptor.php(146): Magento\Framework\Session\SessionManager->start()
#6 /usr/share/nginx/magento2/var/generation/Magento/Framework/Session/Generic/Interceptor.php(52): Magento\Framework\Session\Generic\Interceptor->___callPlugins('start', Array, Array)
#7 /usr/share/nginx/magento2/vendor/magento/framework/Session/SessionManager.php(130): Magento\Framework\Session\Generic\Interceptor->start()
#8 /usr/share/nginx/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 /usr/share/nginx/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 /usr/share/nginx/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(89): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\\Framewo...', Array)
#11 /usr/share/nginx/magento2/vendor/magento/framework/ObjectManager/ObjectManager.php(71): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Framewo...')
#12 /usr/share/nginx/magento2/var/generation/Magento/Framework/Session/Generic/Proxy.php(84): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Framewo...')
#13 /usr/share/nginx/magento2/var/generation/Magento/Framework/Session/Generic/Proxy.php(207): Magento\Framework\Session\Generic\Proxy->_getSubject()
#14 /usr/share/nginx/magento2/vendor/magento/framework/Url.php(942): Magento\Framework\Session\Generic\Proxy->getSessionIdForHost('https://www......')
#15 /usr/share/nginx/magento2/vendor/magento/framework/Url.php(1096): Magento\Framework\Url->_prepareSessionUrl('https://www......')
#16 /usr/share/nginx/magento2/vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(78): Magento\Framework\Url->getRedirectUrl('https://www.......')
#17 /usr/share/nginx/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))
#18 /usr/share/nginx/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')
#19 /usr/share/nginx/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))
#20 /usr/share/nginx/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))
#21 /usr/share/nginx/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...')
#22 /usr/share/nginx/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))
#23 /usr/share/nginx/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))
#24 /usr/share/nginx/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...')
#25 /usr/share/nginx/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))
#26 /usr/share/nginx/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))
#27 /usr/share/nginx/magento2/var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
#28 /usr/share/nginx/magento2/vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#29 /usr/share/nginx/magento2/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
#30 /usr/share/nginx/magento2/pub/index.php(37): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#31 {main}";s:3:"url";s:1:"/";s:11:"script_name";s:10:"/index.php";}

And here is the content of /usr/share/nginx/magento2/vendor/magento/framework/Session/SaveHandler/Native.php

<?php
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Magento\Framework\Session\SaveHandler;

/**
 * Php native session save handler
 */
class Native extends \SessionHandler
{
    /**
     * Workaround for php7 session_regenerate_id error
     * @see https://bugs.php.net/bug.php?id=71187
     *
     * @param string $sessionId
     * @return string
     */
    public function read($sessionId)
    {
        return (string)parent::read($sessionId);
    }
}

Can anyone tell me what the problem might be?

4 Answers 4

4

I have faced same issue On my shared server.

So what I did is open my env.php file and

find

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

and replace with (I created session folder in var directory of my magento)

array (
  'save' => 'files',
  'save_path' => 'var/session',
),
1
  • 2
    For me array ( 'save' => 'files', 'save_path' => '/tmp', ),
    – Sfblaauw
    Commented Nov 15, 2018 at 11:12
2

Add below session code php.ini file at end of file

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

to

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

Edited php.env file:

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

to

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

Let me know if you still got an issue.

1

php package has some pre|post installation scenario in its specfile, and one of commands is:

......
%dir %attr(0770, root, apache) "/var/lib/php/session"
......

so im afraid that probably all your changes will be overwritten on the next php upgrade. no need to chmod or change owner anyway.

you have one option to properly fix it:

open your php-fpm pool config file /etc/php-fpm.d/www.conf and change these lines at the bottom:

php_value[session.save_handler] = files
php_value[session.save_path]    = /path/to/magento/var/session

or remove them and use redis or memcached.

0
0

The problem that user of php-fpm process do not have write access to /var/lib/php/session/* files. Please find out username and user group and change access on folder like

sudo chown -R www-data:www-data /var/lib/php/

or if it developer environment you can simple (but not secure) add access for all

sudo chmod -R 0777 /var/lib/php/ 
4
  • This could cause issues, depending on how you set up your server. All users that need write access to the Magento file system should share the same group and you should not set world-writable permissions. Look at our file system ownership and permissions and let us know if it works for you. Commented Jul 5, 2016 at 12:36
  • @SteveJohnson So I went to see my "www.conf" -file and checked out the user, and it was nginx. I used following command: > sudo chown -R nginx:nginx /var/lib/php/ This fixed the "There has been an error processing your request" -problem, but now the site is giving me "404 Not Found" on every single page and I can see a stripped-down version of my site. I have added a link to a picture, to better demonstrate the current problem: dl.dropboxusercontent.com/u/96826437/Errors/404_Not_Found.png
    – MyrkkyMies
    Commented Jul 6, 2016 at 3:42
  • you need to delete cache and deploy static content
    – MagenX
    Commented Jul 30, 2016 at 8:13
  • still getting error any help thanks
    – zus
    Commented Jun 3, 2020 at 5:59

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.