Xaretre Xaretre - 3 months ago 21
PHP Question

Cannot find save handler 'redis' - Ubuntu

I am running LAMPP on ubuntu with PHP 5.6.23.

I decided to store my sessions in the Redis and I installed it. I also installed Predis too.

As a searched in the web I changed my php.ini to :

session.save_handler = redis
session.save_path = "127.0.0.1:6379"


But when tried create a session I am taking this error:

Warning: session_start(): Cannot find save handler 'redis' - session startup failed in /path/to/the/Untitled.php


You can think that there is a problem in Redis but it's not. It's working properly I can set something and I can check it with Redis-CLI :

My redis 'set' PHP code is :

<?php

require "predis/autoload.php";
$redis = new Predis\Client([
'scheme' => 'tcp',
'host' => '127.0.0.1',
'port' => 6379,
]);
$redis->set('x', '42');
$redis->set('name','test');

?>


Results in telnet:

Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
MONITOR
+OK
KEYS *
+1471853424.389215 [0 127.0.0.1:36912] "KEYS" "*"
*2
$4
name
$1
x


Session php code:

<?php
session_start();


$count = isset($_SESSION['cont']) ? $_SESSION['cont'] : 1;

echo $count;

$_SESSION['cont'] = ++$count;
?>


It must increase the number every refresh but It just displays an error.

I re-Installed Redis again (v 3.2.3) but still no difference.

Is there any way to solve it?

Could LAMPP be the reason of problem?

EDIT:

I started to use phpredis instead of predis.

Answer

You try different things. Predis is a direct client to your Redis Server. If you want to use them as your session handler you have to install the php module.

sudo apt-get install php5-redis

or for PHP7

sudo apt-get install php7.0-redis

Then "redis" should be available as session handler.

Comments