標籤:php5 mysql php redis windows
一,安裝redis
1.下載安裝包
https://github.com/MSOpenTech/redis/releases/
選擇一個最新版本 redis-2.8.19.zip
2.解壓到一個指定目錄
D:\redis-2.8.19
3.在cmd視窗,進入指定目錄,使用以下命令啟動服務
redis-server.exe redis.windows.conf
4.雙擊開啟 redis-cli.exe ,如果不報錯,就連上了本機伺服器,測試下set,get命令
127.0.0.1:6379> set key test
OK
127.0.0.1:6379> get key
"test"
二,安裝redis擴充
1.下載安裝包,注意使用的版本
https://github.com/phpredis/phpredis/downloads
如果沒有你要的版本可以到這個連結下看看
http://windows.php.net/downloads/pecl/snaps/redis/2.2.5/
2.將下載的php_igbinary.dll,php_redis.dll放在php擴充目錄中(ext)
3.修改設定檔php.ini(添加extension=php_igbinary.dll,extension=php_redis.dll,並且extension=php_igbinary.dll要放到extension=php_redis.dll之前,否則php將報錯誤)
4.重新啟動服務,查看phpinfo(),尋找redis擴充是否安裝成功
三,使用php串連測試
$redis
=
new
Redis();
$redis
->connect(
"127.0.0.1"
,
"6379"
);
$redis
->set(
"say"
,
"Hello World"
);
echo
"<br/>"
.
$redis
->get(
"say"
);
$array
=
array
(
‘first_key‘
=>
‘first_val‘
,
‘second_key‘
=>
‘second_val‘
,
‘third_key‘
=>
‘third_val‘
);
$array_get
=
array
(
‘first_key‘
,
‘second_key‘
,
‘third_key‘
);
$redis
->mset(
$array
);
echo
"<br/>"
;
print_r(
$redis
->mget(
$array_get
));
windows下安裝並使用redis