Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Windows 綜合教學 >> 關於 Windows

Windows 安裝 Redis 基礎教學:下載、啟動服務、PHP 整合測試

編輯:關於 Windows

Windows 環境快速部署 Redis 並整合 PHP:

1. 下載與安裝

  • 下載 redis-2.4.5-win32-win64.zip,解壓依系統選 32/64 位元,路徑加入環境變數。

2. 啟動服務端與客戶端

  • CMD 執行 redis-server.exe,顯示啟動成功資訊。
  • 新開 CMD 執行 redis-cli.exe -h 127.0.0.1 -p 6379 連線測試。

Redis 服務端啟動成功

Redis 客戶端連線測試

3. PHP 整合測試

  • 下載 php_redis.dll 對應 PHP 版本,放入 ext 目錄,php.ini 加入 extension=php_redis.dll。
  • 重啟 Web 服務,撰寫測試碼:
    <?php $redis = new Redis(); $redis->connect('127.0.0.1', 6379); $redis->set('test', 'hello'); echo $redis->get('test'); ?>

輸出 hello 即代表整合成功。Redis 於 Windows 開發測試極為方便,生產環境建議使用 Linux 部署。

Copyright © Windows教程網 All Rights Reserved