下載文件
附件有memcached的安裝文件和php5.2到php5.6的memcache擴展文件,php_redis.dll下載地址:http://windows.php.net/downloads/pecl/releases/redis/2.2.7/
安裝擴展
解壓memcached那個壓縮文件到任意位置,比如說D盤datas文件夾下。找到cmd.exe(c:\windows\system32\cmd.exe),右鍵以管理員方式運行(否則會提示failed to install service or service already installed),輸入D:回車,接着cd到memcached解壓的那個文件夾下執行memcached -d install命令安裝,回車,如果沒有任何提示則表示安裝成功,再輸入memcached -d start回車,開啟memcached進程,如圖所示,可以在服務中看到memcached正在運行
開啟擴展
將附件中php_memcache擴展解壓到php安裝目錄下的ext文件夾中,選擇好適應的版本,之前安裝的php版本是php-5.5.37-Win32-VC11-x64,從phpinfo函數可以看出php版本信息,如下圖,所以我選擇了php5.5-ts-vc11-x64版本的php_memcache擴展,在php.ini中extension添加一條extension=php_memcache.dll,同理將下載的phpredis擴展解壓到php安裝目錄下的ext文件夾中,在php.ini中extension添加一條extension=php_redis.dll
重啟Apache服務器
打開測試文件寫入phpinfo()函數,如圖所示則表示擴展安裝成功。
繼續編輯測試文件 輸入如下代碼
<?php //phpinfo(); $memcache = new Memcache(); $memcache->connect('127.0.0.1', 11211 ) or die ( "Could not connect Memcached server!" ); $memcache->set( 'Memcache', "hello Memcache!<br/>"); echo $memcache->get('Memcache'); echo "<br>"; $redis = new Redis(); $redis->connect("192.168.1.103","6379"); //php客戶端設置的ip及端口 //存儲一個值 $redis->set("say","Hello redis "); echo $redis->get("say"); //Hello redis ?>
輸出hello Memcache!配置成功!
附件:
http://files.cnblogs.com/files/weblm/memcached%E6%89%A9%E5%B1%95.rar
轉載:http://www.cnblogs.com/weblm/p/5793030.html#_labelTop