duanjigua5753 2016-08-22 08:18
浏览 175
已采纳

找不到保存处理程序'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.

  • 写回答

1条回答 默认 最新

  • douben7493 2016-08-22 08:29
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。