折騰了1個多小時,終於搞定。操作系統時64位的,php5.3.13
類似於上一篇的xdebug安裝教程~~
memcache和memcached的區別
在自己的新程序中打算全面應用memcached技術,這個很容易理解這是memcached是內存緩存,但是怎麼還有memcache呢?
其實很簡單,memcache是php的一個擴展,用於php管理memcached,php-memcache.dll。
如果安裝了memcached不安裝擴展,那麼php無法操控memcached,但是命令行使用起來沒有問題
如果安裝了memcache擴展但是沒有安裝memcached服務,那麼這個就無法使用
只有同時安裝了memcached服務和memcache擴展才可以在PHP中使用memcached提高動態網站性能
一、安裝memcache的php擴展
1. php_memcache.dll 下載:
例如:D:\WampServer\bin\php\php5.3.11\ext\php_memcache.dll
3. 打開 php.ini 文件:
我的php.ini的位置:D:\WampServer\bin\php\php5.3.11\php.ini
4. 在 php.ini上增加一行:
extension=php_memcache.dll
5. 重啓Wampserver的apache服務
二、安裝memcached
1. Memcached-win64 下載:
a. 下載最新版:http://blog.couchbase.com/memcached-windows-64-bit-pre-release-available
b. 直接下載: memcached-win64-1.4.4-14.zip
D:\WampServer\bin\memcached\memcached.exe
3. 在終端(也即cmd命令界面)下輸入以下命令安裝windows服務:
D:\WampServer\bin\memcached>memcached.exe -d install
4. 再輸入下面命令啓動:
D:\WampServer\bin\memcached>memcached.exe -d start
OK~~大功告成
打開phpinfo()頁面:
=========== 代碼測試 =============
01 |
$memcache = new Memcache; |
02 |
$memcache ->connect( "localhost" ,11211);
# You might need to set "localhost" to "127.0.0.1" |
04 |
echo "Server's
version: " . $memcache ->getVersion()
. "\n" ; |
06 |
$tmp_object = new stdClass; |
07 |
$tmp_object ->str_attr
= "test" ; |
08 |
$tmp_object ->int_attr
= 123; |
10 |
$memcache ->set( "key" , $tmp_object ,false,10); |
11 |
echo "Store
data in the cache (data will expire in 10 seconds)\n" ; |
13 |
echo "Data
from the cache:\n" ; |
14 |
var_dump( $memcache ->get( "key" )); |
結果:
01 |
----------
PhpUnit ---------- |
02 |
Server's
version: 1.4.4-14-g9c660c0 |
03 |
Store
data in the
cache (data will expire in 10
seconds) |
12 |
Output
completed (2 sec consumed) - Normal Termination |
參考:http://www.2cto.com/os/201207/140485.html