安裝PHP及Memcache擴充

來源:互聯網
上載者:User

1. 下載

(1)libevent

官方網頁:http://monkey.org/~provos/libevent/

下載命令:

wget http://monkey.org/~provos/libevent-2.0.13-stable.tar.gz

(2)libmemcached

官方網頁:https://launchpad.net/libmemcached/+download

下載命令:

wget http://launchpad.net/libmemcached/1.0/0.52/+download/libmemcached-0.52.tar.gz

(3)PHP

官方網頁:http://cn2.php.net/get/php-5.3.8.tar.gz/from/a/mirror

下載命令:

wget http://cn2.php.net/get/php-5.3.8.tar.gz/from/cn.php.net/mirror

(4)Memcached伺服器端

官方網頁:http://memcached.org/

下載命令:

wget http://memcached.googlecode.com/files/memcached-1.4.7.tar.gz

(5)Memcache For PHP Module

官方網頁:http://pecl.php.net/package/memcache

下載命令:

wget http://pecl.php.net/get/memcache-3.0.6.tgz

2. 安裝Memcached伺服器端

(1)安裝libevent

tar -zxvf libevent-2.0.13-stable.tar.gzcd libevent-2.0.13-stable./configuremakemake install

(2)安裝Memcached

tar -zxvf memcached-1.4.7.tar.gzcd memcached-1.4.7./configure --prefix=/usr/local/memcachedmakemake install

3. 安裝PHP

(1)安裝libxml2

sudo apt-get install libxml2-dev

(2)解壓編譯

tar -zxvf php-5.3.8.tar.gzcd php-5.3.8./configuremakemake install

4. 安裝Memcache for PHP Module

(1)解壓編譯

tar -zxvf memcache-3.0.6.tgzcd memcache-3.0.6/usr/local/bin/phpize./configure --enable-memcache --with-php-config=/usr/local/php5/bin/php-config --with-zlib-dirmakemake install

在運行 "make install" 的後,得到:

Installing shared extensions:     /usr/local/lib/php/extensions/no-debug-non-zts-20090626/

(2)修改php.ini檔案

找到如下代碼:

extension_dir = "./"

修改為 make install 後得到的目錄。

extension = "/usr/local/lib/php/extensions/no-debug-non-zts-20090626/"

增加 extension 屬性,設定為

extension = memcache.so

5. 測試

(1)編寫測試檔案

<?php        $mem = new Memcache;        $mem->connect("127.0.0.1", 12121);        $mem->set('key', 'This is a test!', 0, 60);        $val = $mem->get('key');        echo $val;?>

(2)運行測試檔案

php -c /etc/php5/cgi/php.ini test.php

(3)結果檢驗

如果沒有error,就是OK了。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.