Windows下安裝Redis及php的redis拓展教程

來源:互聯網
上載者:User

標籤:連結   fill   dll   啟動命令   evel   fonts   ice   open   eve   

一.安裝前必讀

Windows 64位作業系統

Redis 安裝包(版本3.0.5,截止2017-05-29最新redis版本為3.2.9)

注意事項:

1.在window下如果你還需安裝php的redis拓展,那麼安裝最新版本的redis可能沒有對應的php_redis.dll;

2.網上的windows下安裝redis及PHP拓展教程大多是redis2.x版本的,對於想安裝高版本可能不適用;

3.一開始我安裝的是最新的redis3.2.9版本,在安裝php_redis拓展傻眼了,php_redis.dll沒找到redis3.2版本的,至少我花了很長時間也沒找到,TAT!

來看下截止2017-05-29,可下載的php_redis.dll版本,網站連結https://pecl.php.net/package/redis

 

再來看下截止2017-05-29,windows下redis的版本,git地址https://github.com/MSOpenTech/redis/releases

看到了吧,windows有redis3.2的版本,卻不好找redis3.2對應的php_redis.dll,所以還是推薦大家在選擇redis版本時要注意對應php_redis拓展也能找到!

二.安裝Redis

1.下載redis壓縮包,githttps://github.com/MSOpenTech/redis/releases

這裡我選擇的是3.0.5版本,選擇zip下載

2.下載後解壓到redis檔案夾,以下為解壓後的檔案,安裝完成


redis-cli.exe               # 用戶端
redis-server.exe            # 伺服器
redis.windows.conf          # 設定檔

3.redis測試

windows 運行(快速鍵:windows鍵+R鍵),輸入【cmd】命令,進入DOC作業系統視窗;

進入redis安裝目錄使用命令

[objc] view plain copy 
  1. redis-server  redis.windows.conf  

 

啟動redis 服務,此視窗無需關閉,關閉視窗就停止redis服務了,啟動成功如:

新開啟一個doc視窗,進入安裝目錄執行用戶端啟動命令【redis-cli】或者直接雙擊redis-cli.exe進行測試命令,建立並擷取name值為leesin資料:

三.安裝php的redis拓展

1.下載php_redis.dll,https://pecl.php.net/package/redis

我選擇的是版本3.0.0,對應redis安裝版本3.0的

在新開啟的視窗選擇對應的下載,先查看phpinfo資訊

所以這裡我選64位的nts版本的下載

2.找到php安裝目錄將下載的包裡面的這兩個檔案放到ext檔案夾裡

3.修改php.ini添加

extension=php_redis.dll

開啟redis拓展,儲存並重啟Nginx或Apache伺服器

 

4.驗證是否開啟redis拓展

再次查看phpinfo資訊,搜尋redis,出現即表示成功開啟。

5.php串連並測試redis資料庫

建立test.php

<?php   $redis = new Redis();   $redis->connect(‘127.0.0.1‘,6379);    $redis->set(‘name‘,‘leesin‘);   echo $redis->get(‘name‘);  ?>  

訪問test.php

 

輸出 leesin

 

 

安裝為windows服務

安裝命令: redis-server.exe --service-install redis.windows.conf 使用命令,

安裝成功,所以: 

啟動服務

redis-server --service-start


最後的參數 --loglevel verbose表示記錄日誌等級
安裝之後,windows目前的服務列表 

常用的redis服務命令。

卸載服務:redis-server --service-uninstall

開啟服務:redis-server --service-start

停止服務:redis-server --service-stop

重新命名服務:redis-server --service-name name

 

至此您也全部完成Windows下Redis及php的redis拓展的安裝!

Windows下安裝Redis及php的redis拓展教程

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.