一.在编译安装之前,先安装系统所需要的相关库文件

#yum -y install gcc gcc-c++ make cmake libtool autoconf libaio


二.下载相应的依赖库和memcached源码包

1.从http://libevent.org/下载libevent的stable版本


#wget https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz

#wget http://www.memcached.org/files/memcached-1.5.0.tar.gz


2.编译安装libevent

#tar -zxvf libevent-2.1.8-stable.tar.gz

#cd libevent-2.1.8-stable

#./configure --prefix=/usr/local/libevent

#make && make install


注意:在虚拟机下练习编译,一个容易碰到的问题,虚拟机时间不对,导致gcc编译过程中检测时间不对,一直处于编译过程中。

解决的方法:

#date -s "yyyy-mm-dd H:i:s"

#clock -w #把时间写入cmos


3.编译安装memcache

#tar -zxvf memcached-1.5.0.tar.gz

#cd memcached-1.5.0

#./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent/ #指定libevent的安装目录

#make && make install


4.启动memched

#cd /usr/local/memcached/bin

#./memcached -m 64 -p 11211 -u nobody -d