下載redis-windows-master。解壓點擊redis-server.exe運行服務端php
redis設置訪問密碼redis
修改redis.conf文件配置, # requirepass foobared去掉註釋,foobared改成本身的密碼windows
默認端口6379架構
安裝redis擴展函數
使用phpinfo()函數查看PHP的版本信息,這會決定擴展文件版本ui
根據PHP版本號,編譯器版本號和CPU架構,.net
選擇php_redis-2.2.5-5.5-ts-vc11-x86.zip和php_igbinary-1.2.1-5.5-ts-vc11-x86.zipserver
下載地址:blog
http://windows.php.net/downloads/pecl/snaps/redis/2.2.5/ip
http://windows.php.net/downloads/pecl/releases/igbinary/1.2.1/
三、解壓縮後,將php_redis.dll、php_igbinary.dll和php_redis.pdb、php_igbinary.pdb拷貝至php的ext目錄下。
四、修改php.ini
extension=php_igbinary.dll
extension=php_redis.dll
注意:extension=php_igbinary.dll必定要放在extension=php_redis.dll的前面,不然此擴展不會生效
重啓Apache後,使用phpinfo查看擴展是否成功安裝.搜igbinary和redis能搜到表示安裝完成。
五、新建一個test.php頁面
<?php
$redis=new Redis();
$redis->connect('192.168.1.11',6379);
$redis->auth('123456');
$redis->set('test','helloworld');
$redis->setex('test2',10,$str.'---2');//設置帶時間的參數10秒
echo $redis->get('test');
echo $redis->get('test2');