一、下载memcached
二、安装memcached
命令:
root@startos:/home/cg/Downloads/memcached/memcached-1.4.16# ./configure --prefix=/home/cg/Apps/memcached --with-libevent=/usr/lib/libevent.so
输出信息的最后部分:
checking for libevent directory... configure: error: libevent is required. You can get it from http://www.monkey.org/~provos/libevent/
If it's already installed, specify its path using --with-libevent=/dir/
If it's already installed, specify its path using --with-libevent=/dir/
命令:
root@startos:/home/cg/Downloads/memcached/memcached-1.4.16# ./configure --prefix=/home/cg/Apps/memcached --with-libevent=/usr/lib/libevent-2.0.so.5
输出信息同上。
如何解决这个问题?
三、重新安装libevent(一定不能删除系统默认的libevent,曾经因为删除了它导致系统终端命令不能运行,最后崩溃)
1.下载libevent
wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
命令:
root@startos:/home/cg/Downloads/libevent/libevent-2.0.21-stable# ./configure --prefix=/home/cg/Apps/memcached/libevent
root@startos:/home/cg/Downloads/libevent/libevent-2.0.21-stable# make;make install
失败。
从startos的源码包下载了libevent-dev
http://pkg.startos.org/packages/l/libevent-dev/libevent-dev_2.0.10-i686.ypk
然后用ypkg --install filename默认安装之后,再次执行命令:
root@startos:/home/cg/Downloads/memcached/memcached-1.4.16# ./configure --prefix=/home/cg/Apps/memcached --with-libevent=/usr/lib/
好像成功了。(很关键的步骤。若换成其他方式,能否直接下载libevent-dev然后安装。以后再试。)
make;make install
root@startos:/home/cg/Apps/memcached/bin# ./memcached -d -m 128 -u root -p 11211没有任何输出信息,如何知道memcached是否启动了?
四、安装memchached客户端
1.下载PHP的memcached客户端
命令:
root@startos:/home/cg/Downloads/php# wget http://pecl.php.net/get/memcache-3.0.8.tgz
2.安装PHP的memcached客户端
命令:
root@startos:/home/cg/Downloads/php# tar -xzvf memcache-3.0.8.tgz
命令:
root@startos:/home/cg/Downloads/php/memcache-3.0.8# /home/cg/Apps/LAMP/php/php/bin/phpize
输出信息:
Configuring for:
PHP Api Version: 20121113
Zend Module Api No: 20121212
Zend Extension Api No: 220121212
PHP Api Version: 20121113
Zend Module Api No: 20121212
Zend Extension Api No: 220121212
执行上面的命令后,在memcache下生成了configure文件。
命令:
root@startos:/home/cg/Downloads/php/memcache-3.0.8# ./configure --enable-memcache --with-php-config=/home/cg/Apps/LAMP/php/php/bin/php-config --with-zlib-dir
不明白这条命令中的--with-zlib-dir的作用是什么。
输出信息的最后部分:
creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
说明PHP的memcache客户端安装成功了!
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
没有报错,应该是成功了。
命令:
make;make install
输出信息的最后部分:
Installing shared extensions: /home/cg/Apps/LAMP/php/php/lib/php/extensions/no-debug-zts-20121212/
3.修改PHP的配置文件php.ini,在其中的Dynamic Extensions部分加入
extension = /home/cg/Apps/LAMP/php/php/lib/php/extensions/no-debug-zts-20121212/memcache.so
4.重启apache,查看phpinfo.php的输出信息,增加了

memcache
memcache support | enabled |
---|---|
Version | 3.0.8 |
Revision |
$Revision: 329835 $ |