[英]Cannot find save handler 'redis' - Ubuntu
I am running LAMPP on ubuntu with PHP 5.6.23. 我正在使用PHP 5.6.23在ubuntu上运行LAMPP。
I decided to store my sessions in the Redis and I installed it. 我决定将会话存储在Redis中并进行安装。 I also installed Predis too.
我也安装了Predis。
As a searched in the web I changed my php.ini to : 在网上搜索时,我将php.ini更改为:
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. 您可以认为Redis中存在问题,但事实并非如此。 It's working properly I can set something and I can check it with Redis-CLI :
它工作正常,我可以设置一些东西,并且可以使用Redis-CLI进行检查:
My redis 'set' PHP code is : 我的redis“设置” PHP代码是:
<?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: 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代码:
<?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. 我再次重新安装了Redis(v 3.2.3),但仍然没有区别。
Is there any way to solve it? 有什么办法解决吗?
Could LAMPP be the reason of problem? LAMPP可能是问题的原因吗?
EDIT: 编辑:
I started to use phpredis instead of predis. 我开始使用phpredis而不是predis。
You try different things. 您尝试不同的事情。 Predis is a direct client to your Redis Server.
Predis是Redis Server的直接客户端。 If you want to use them as your session handler you have to install the php module.
如果要使用它们作为会话处理程序,则必须安装php模块。
sudo apt-get install php5-redis
or for PHP7 或对于PHP7
sudo apt-get install php7.0-redis
Then "redis" should be available as session handler. 然后,“ redis”应可用作会话处理程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.