客户端 Memcache 安装:

1. 下载安装

mkdir -p /root/soft
cd /root/soft
wget -c http://pecl.php.net/get/memcache-3.0.6.tgz
tar -zxvf memcache-3.0.6.tgz
cd memcache-3.0.6
/usr/local/php/bin/phpize
./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config --with-zlib-dir
make
make install
cp /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/memcache.so /usr/local/php/lib/php/
sed -i 's#; extension_dir = "./"#extension_dir = "/usr/local/php/lib/php"#' /usr/local/php/lib/php.ini


2. 修改PHP配置:vim /usr/local/php/lib/php.ini

大约986行下面加上: extension=memcache.so
重启生效:/usr/local/apache2/bin/apachectl restart


3. 测试 vim /code/2.php 内容如下


$memcache = new Memcache;
$memcache->connect('localhost', 11213) or die ("Could not connect");
$memcache->set('key', 'test - 哈哈测试!');
$get_value = $memcache->get('key');
echo $get_value;

?>