Memcache是什麼
Memcache是danga.com的一個項目,最早是為 LiveJournal 服務的,目前全世界不少人使用這個快取項目來構建自己大負載的網站,來分
擔資料庫的壓力。
它可以應對任意多個串連,使用非阻塞的網路IO。由於它的工作機制是在記憶體中開闢一塊空間,然後建立一個HashTable,Me
mcached自管理這些HashTable。
Memcache官方網站:http://memcached.org/,更多詳細的資訊可以來這裡瞭解
為什麼會有Memcache和memcached兩種名稱?
其實Memcache是這個項目的名稱,而memcached是它伺服器端的主程式檔案名稱,知道意思了吧~~~~。
一個是項目名稱,一個是主程式檔案名稱,在網上看到了很多人不明白,於是混用了。
官方原文:
What is Memcached?
Free & open source, high-performance, distributed memory object caching system, generic in nature, but intend
ed for use in speeding up dynamic web applications by alleviating database load.
Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database
calls, API calls, or page rendering.
Memcached is simple yet powerful. Its simple design promotes quick deployment, ease of development, and solves man
y problems facing large data caches. Its API is available for most popular languages.
Memcache的安裝
分為兩個過程:memcache伺服器端的安裝和memcached用戶端的安裝。
所謂伺服器端的安裝就是在伺服器(一般都是linux系統)上安裝Memcache實現資料的儲存
:http://pecl.php.net/package/memcache
所謂用戶端的安裝就是指php(或者其他程式,Memcache還有其他不錯的api介面提供)去使用伺服器端的Memcache提供的函數,需要
php添加擴充。
:http://code.google.com/p/memcached/downloads/list
首先要安裝Apache,其安裝配置
: http://httpd.apache.org/download.cgi
下載一個for windows 的,如
Win32 Binary without crypto (no mod_ssl) (MSI Installer): httpd-2.2.15-win32-x86-no_ssl.msi [PGP] [MD5] [SHA1]
Win32 Binary including OpenSSL 0.9.8m (MSI Installer): httpd-2.2.15-win32-x86-openssl-0.9.8m-r2.msi [PGP] [MD5] [SHA1]
注,看說明,如果安裝了OpenSSL的就不用再裝了,否則裝下面的版本;
Apache是傻瓜式安裝..(注意,如果您系統上裝有IIS或其他Web伺服器,請先停止其工作),
安裝完畢後訪問http://localhost會提示伺服器正在工作:It works!
安裝PHP
:http://windows.php.net/download
本人下載的是:http://windows.php.net/downloads/releases/php-5.3.2-Win32-VC6-x86.zip
最好不要使用安裝包,因為它不包含擴充部分,而您可能在你的項目中使用到這部分內容,按照下面部分配置PHP:
a.解壓壓縮包到E:\php-5.3.2-Win32-VC6-x86\ 檔案夾下(可選擇其它盤)
b.將php.ini-recommended 從 E:\php-5.3.2-Win32-VC6-x86\ 複製到Windows檔案夾下,重新命名為PHP.ini
c.開啟PHP.ini,將php_gd2.dll、php_mysql.dll、php_mysqli.dll、php_xsl.dll改為extension(簡單地說,就是把它們前面的分號去掉)
d.建議在開發環境下發送錯誤報表(此步驟可選),在PHP.ini中找到error_reporting一行,並修改為:error_reporting=e_all
e.將E:\php-5.3.2-Win32-VC6-x86\ 下的php5ts.dll、libmysql.dll (如果php裡面沒有這個東東,就直接從MySQL的安裝目錄中,
E:\mysql-5.1.39-win32\lib\debug直接copy )複製到Windows的system32檔案夾下
f.將E:\php-5.3.2-Win32-VC6-x86\ext\ 下的php_gd2.dll、php_mysql.dll、php_mysqli.dll、php_xsl.dll複製到Windows的system32檔案夾下
g.開啟Apache設定檔httpd.conf,找到許多LoadModule條目的部分,添加以下內容:
LoadModule php5_module E:/php-5.3.2-Win32-VC6-x86/php5apache2_2.dll
找到<IfModule mime_module>,在其相應位置下添加以下內容 AddType application/x-httpd-php .php h.找到DirectoryIndex條目,改成以下內容:
DirectoryIndex index.html index.html.var index.php
i.儲存檔案,然後重新啟動Apache伺服器
j.在E:\Program Files\Apache Software Foundation\Apache2.2\htdocs目錄 (此為網站預設路徑,可以改配置,只需搜尋此部分,
把它改成實際的路徑即可,
注意,\要全部換成/)下,刪除原有檔案,建立名為index.php的檔案,內容如下:
<?php
phpinfo();
?>
k.最後,在瀏覽器輸入網址http://localhost/index.php,你會看到相關PHP資訊的頁面
l.搞掂,成功!
安裝pear
pear是PHP的擴充和應用程式庫,包含了很多有用的類,安裝好php5.0後,pear實際上並沒有被安裝;
安裝如下:
從http://pear.php.net/manual/en/installation.getting.php擷取http://pear.php.net/go-pear中的代碼
並儲存名為go-pear.php檔案,放到任一個檔案夾下,如E:\php-5.3.2-Win32-VC6-x86\go-pear.php(放在PHP的安裝目錄下最好)
然後開啟命令控制台,定位到go-pear.php目錄,
輸入命令:php go-pear.php
開始安裝,根據不同情況選擇....其實選擇預設的就可以了
重啟Apache;
****************************************************************************************************
修改my.ini
Modifying php.iniTo get PEAR working properly, you need to adjust PHP's include_path. After you found php.ini, open it in an editor.
Search for the line include_path.
Now that you found it, you probably will see a semicolon ; at the beginning. This means the line is a comment.
Add a new line below it.
In this line, write:
include_path="."
Depending on your operating system, add a : (Unix/Linux/FreeBSD/Mac OS X) or a ; (Windows) after the dot.
Add PEAR's php_dir after it.
(The directory System.php is located in!)
The result should look like that:
; Unixinclude_path=".:/usr/local/php/pear/"
or
; Windowsinclude_path=".;E:\php-5.3.2-Win32-VC6-x86\PEAR\"
應該看懂上面的英文,(簡單,不想翻譯了)
***********本人感覺這裡為可選設定,因為安裝的時候有提示修改,可是後來我發現沒修改,但是能夠使用..冒汗中**********
詳細介紹請看http://pear.php.net/manual/en/installation.getting.php與
http://pear.php.net/manual/en/installation.checking.php#installation.checking.cli.modifyingphpini
再+
http://pear.php.net/package/PEAR/download/All
配置完成,謹以此記錄.....