【问题标题】:enable redis on xampp in windows在 Windows 中的 xampp 上启用 redis
【发布时间】:2018-01-12 06:07:05
【问题描述】:

我正在尝试让redis在xampp上工作,我的xampp在windows 10上是32位,php版本是5.6,我在这里下载redis

http://pecl.php.net/package/redis/2.2.7/windows(x86 线程安全的),并添加了

extension=php_redis.dll in php.ini,我用linux安装在virtualbox上的redis服务器(selinux被禁用)

这是我在 Windows 上运行的脚本

<?php 

   //Connecting to Redis server on localhost 
   $redis = new Redis(); 
   $redis->connect('192.168.0.108', 6379); 
   echo "Connection to server sucessfully";

    var_dump($redis);   
    $redis->set("say","Hello World");
    echo $redis->get("say");

?>

错误显示:

Connection to server sucessfullyobject(Redis)#1 (0) { } 
Fatal error: Uncaught exception 'RedisException' with message 
'Redis server went away' in 
D:\xampp\htdocs\test\redis\test.php:8 Stack trace: #0 
D:\xampp\htdocs\test\redis\test.php(8): Redis->set('say', 'Hello World') #1 {main} thrown in 
D:\xampp\htdocs\test\redis\test.php on line 8

谁知道是什么问题?我是否正确安装了扩展程序?

【问题讨论】:

    标签: php redis xampp


    【解决方案1】:

    您需要确定您的 redis-server 是否正在侦听端口 6379,例如:

    redis-cli -h 192.168.0.108
    

    它必须回应:

    192.168.0.108:6379>
    

    确定答案后,你的连接就会成功。

    相关问题:

    Fatal error: Uncaught exception 'RedisException' with message 'Redis server went away'

    【讨论】:

    • 我的服务器以 redis-cli 响应,但我仍然在 php 代码中得到 server went away。任何想法为什么会发生这种情况?我正在使用 PHP 7
    猜你喜欢
    • 2018-04-13
    • 2013-01-06
    • 2020-05-17
    • 2020-03-05
    • 2012-08-01
    • 2013-06-04
    • 2016-05-30
    • 2013-03-05
    • 1970-01-01
    相关资源
    最近更新 更多