redis&memcached for windows 安装与使用

来源:互联网 发布:网络策划是什么 编辑:程序博客网 时间:2024/05/16 14:16
redis for windows
很简单只需要3步,主要是安装redis和安装php的redis扩展两个方面(安装玩之后应该进行一定配置
1.Windows安装包下载地址:https://github.com/ServiceStack/redis-windows(注意,很多地址是linux的安装包,没有exe文件)https://github.com/mythz/redis-windows
windows安装redis,推荐博客:http://www.cnblogs.com/xshang/p/3800205.html,我按照次安装成功。
2.去下载php相应版本的dell文件,安装extension=php_igbinary.dll扩展,放入php的ext目录下
3.配置php:(注意保持这个顺序)
extension=php_igbinary.dll
extension=php_redis.dll
成功,查看phpinfo()信息。
--------------------------------建议使用以下安装方法将redis安装为服务,然后设置自启动

1,在redis的目录下执行(执行后就作为windows服务了)

redis-server --service-install redis.windows.conf

2,安装好后需要手动启动redis

redis-server --service-start
3,停止服务
redis-server --service-stop

4,卸载redis服务

redis-server --service-uninstall
//--------------详细步骤----------------------------------------------------------------

window下安装redis

       在window下安装redis,首先下载redis,解压放到一个目录下,比如D:\redis\

       在控制台下切换到D:\redix

       输入:redis-server.exe  redis.conf

       然后重新打开一个cmd控制台,仍然切换到D:\redis\下

       输入:redis-cli.exe -h 127.0.0.1 -p 6379

       之后就可以使用了,比如继续输入:set test "hello world"

       接着输入 get test

       就会返回 hello world

      --------------------------------------------------------------------------------------------------------

      在php下使用redis,要用到php_redis.dll,下载对应版本,放到php下的ext目录下,然后

      需要配置php.ini,加入extension=php_redis.dll

      在查看需要php_redis哪个版本时,可以用

      <?php   echo phpinfo(); ?>进行测试

      然后,重启wamp

      再用

      <?php echo phpinfo(); ?>测试

      看到redis时,表示安装成功了

memcached for windows
http://www.runoob.com/memcached/window-install-memcached.html下载

1、下载memcache的安装包,要选择win环境的安装包

2、把解压后放到D盘(以D:/memcached为例)

3、点击开始=》运行=》输入cmd进入dos界面。
4、输入 d:  命令进入d盘,输入 cd memcached 命令进入memcached文件夹

5、输入 memcache.exe –d install 命令安装,输入memcache.exe –d start 启动memcached进程。停止命令 memcached.exe -d stop, 卸载命令memcached.exe -d unistall

6、进入任务管理器,查看进程,如下图则安装成功:memcached.exe
7、下载 php_memcache.dll扩展文件,放到wamp安装目录下的bin\PHP\php5.5.12\ext目录下

8、打开php.ini,加入 extension=php_memcache.dll ,注意前面没有分号,保存后重新启动服务

9、在本地新建项目memcached,添加index.php执行文件,输入代码如下:
    $memcache=new Memcache();
    $memcache->connect('127.0.0.1',11211);
    $memcache->add('name2','fesfarige',false,60);
    $val=$memcache->get('name2');
    echo $val;
成功则输出fesfarige

e:\phpToStudy\memcached> memcached.exe -m 1 -d start

(2). 停止memcached:

   memcached.exe -d stop

(3). 卸载memcached:

   memcached.exe -d uninstall