在Windows32下为PHP5.6安装redis扩展和memcached扩展

一.php安装redis扩展

 

1.使用phpinfo()函数查看PHP的版本信息,这会决定扩展文件版本

 在Windows32下为PHP5.6安装redis扩展和memcached扩展

 

 

 在Windows32下为PHP5.6安装redis扩展和memcached扩展

 

2.根据PHP版本号,编译器版本号和CPU架构,

选择php_redis-2.2.5-5.6-ts-vc11-x86.zip和php_igbinary-1.2.1-5.5-ts-vc11-x86.zip

下载地址:

http://pecl.php.net/downloads/package/redis/2.2.5/

http://pecl.php.net/downloads/package/igbinary/1.2.1/

 

 在Windows32下为PHP5.6安装redis扩展和memcached扩展

在Windows32下为PHP5.6安装redis扩展和memcached扩展

 

 

 

 

3.解压缩后,将php_redis.dll和php_igbinary.dll拷贝至php的ext目录下

 在Windows32下为PHP5.6安装redis扩展和memcached扩展

 

 

 

 

4.修改php.ini,在该文件中加入:

; php_redis

extension=php_igbinary.dll

extension=php_redis.dll

注意:extension=php_igbinary.dll一定要放在extension=php_redis.dll的前面,否则此扩展不会生效

 在Windows32下为PHP5.6安装redis扩展和memcached扩展

 

 在Windows32下为PHP5.6安装redis扩展和memcached扩展

 

 

 

 

5.重启Apache后,使用phpinfo查看扩展是否成功安装

 

 在Windows32下为PHP5.6安装redis扩展和memcached扩展

新建一个test.php页面

<?php
    $redis = new Redis();
    $redis->connect('127.0.0.1',6379);
    $redis->set('test','hello redis');
    echo $redis->get('test');
?>

 

hello redis

 

 

6. 要在Windows中使用redis需要下载Windows版的redis软件

下载地址:https://github.com/dmajkic/redis/downloads下载php_redis-2.2.5-5.6-ts-vc11-x86

 运行demo的时候记得打开redis服务:cd命令切换目录到 C:\redis 运行 redis-server.exe redis.conf 。

 

 

 

 

二.php安装memcache扩展

 

windows 7 64bit 环境下安装memcached

1、下载后解压到D:\memcached(下载地址:memcached-win64下载地址)

 在Windows32下为PHP5.6安装redis扩展和memcached扩展

 

 

2、安装到windows服务,打开cmd命令行,进入memcached目录,执行:memcached -d install命令,安装服

如果在没有安装过的情况下,出现"failed to install service or service already installed"错误,则是cmd.exe需要用管理员身份运行。

 在Windows32下为PHP5.6安装redis扩展和memcached扩展

 

 

3.启动服务,执行:memcached -d start

 

4. 安装PHP Memcache扩展

    下载正确版本的php_memcache.dll动态链接库文件 ,并放在php5.6.16\ext目录下 。

5.编辑php.ini,添加下面一行代码到php.ini文件中。

    extension=php_memcache.dll

6.在phpinfo中查看memcache扩展是否安装成功。

 

 在Windows32下为PHP5.6安装redis扩展和memcached扩展