Windows下為PHP安裝redis擴充

來源:互聯網
上載者:User

標籤:測試   ace   csharp   highlight   ice   注意   tutorial   src   binary   

1.使用phpinfo()函數查看PHP的版本資訊,這會決定擴充檔案版本。

2.下載php_igbinary-2.0.1-7.0-ts-vc14-x64.zip,php_redis-3.1.3rc2-7.0-ts-vc14-x64.zip(一定要保證版本的正確性)

:【選擇適合的版本】

http://windows.php.net/downloads/pecl/snaps/redis/

http://windows.php.net/downloads/pecl/releases/igbinary/

ps:如果在PHP目錄下看到php7ts.dll則選擇ts版本

3.解壓縮後,將php_redis.dll和php_redis.pdb拷貝至php的ext目錄下

4.修改php.ini,(PS:此php.ini檔案是在Apache目錄)在該檔案中加入:

; php_redis

extension=php_igbinary.dll

extension=php_redis.dll

注意:extension=php_igbinary.dll一定要放在extension=php_redis.dll的前面,否則此擴充不會生效

5.重啟Apache後,使用phpinfo查看擴充是否成功安裝

6.開啟redis服務後,可以用如下測試是否能夠調用。

 <?php  //串連本地的 Redis 服務  $redis = new Redis();  $redis->connect(‘127.0.0.1‘, 6379); echo "Connection to server sucessfully";  //設定 redis 字串資料  $redis->set("tutorial-name", "Redis tutorial");  // 擷取儲存的資料並輸出  echo "Stored string in redis:: " . $redis->get("tutorial-name"); ?>

  ps:在運行前須開啟本地的redis服務【:https://redis.io/download】

其實Redis是可以安裝成windows服務的,開機自啟動,命令如下:

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

安裝完之後,就可看到redis已經作為windows服務了:

但是安裝好之後,Redis並沒有啟動,

啟動命令如下:

redis-server --service-start

停止命令:

redis-server --service-stop

還可以安裝多個執行個體

redis-server --service-install –service-name redisService1 –port 10001redis-server --service-start –service-name redisService1redis-server --service-install –service-name redisService2 –port 10002redis-server --service-start –service-name redisService2redis-server --service-install –service-name redisService3 –port 10003redis-server --service-start –service-name redisService3

卸載命令:

redis-server --service-uninstall

Windows下為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.