wampserver 安装phpredis扩展

wampserver 安装phpredis扩展

注意的是,ts线程安全的是apache对应,而nts是IIS对应。

1、首先要查看自己的wanpserver的软件信息:phpinfo()

2、根据上面的信息找到相对应的版本进行下载

 下载地址:

  
  igbinary下载:https://windows.php.net/downloads/pecl/releases/igbinary

  redis下载:http://windows.php.net/downloads/pecl/releases/redis/

3、解压下载的压缩包得到php_igbinary.dll 和 php_redis.dll,然后将这两个文件放到对应的php扩展目录中(ext),并修改php.ini配置(注意:是apache中的php.ini):

;添加以下扩展:

extension=php_igbinary.dll

extension=php_redis.dll

注意添加扩展的顺序:先 igbinary  后 redis

4、重启所有wampserver服务,然后查看phpinfo(),下面结果表示成功

 5、在PHP中使用redis

 //连接本地的 Redis 服务
    $redis = new Redis();
    try{
        $redis->connect('127.0.0.1', 6379); // 服务不存在时,返回:Redis server went away
        //查看服务是否运行
        $redis->auth("foobared");//因为redis服务器启动了AUTH验证
    }catch(Exception $e){
        die($e->getMessage());
    }


    echo "Connection to server sucessfully";
    
    echo "Server is running: " . $redis->ping();

猜你喜欢

转载自www.cnblogs.com/hysen/p/9263600.html