原文:http://www.cnblogs.com/czh-liyu/archive/2010/04/27/1722084.html
memcached 安装需要依赖GCC和libevent,所以首先要安装这2款软件。
进入tmp目录,下载对应的软件
cd tmp
一、安装GCC
GCC一般linux都会自带,用gcc -v 查看是否安装了。如没有安装GCC,使用如下命令安装GCC:
yum install gcc
二、安装libevent
libevent 是安装 memcached 的前提条件。它是 memcached 所依赖的异步事件通知库。您可以在 monkey.org 上找到关于 libevent 的源文件。接下来,找到其最新版本的源文件。对于本文,我们使用稳定的 2.0.21 版本。
1. 下载libevent
wget http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
2. 安装libevent
tar zxvf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
./configure --prefix=/usr/local/libevent
make
make install
指定安装目录:--prefix=/usr/local/libevent
三、安装memcached
1. 下载memcached
wget http://memcached.org/files/memcached-1.4.20.tar.gz
2. 安装memcached
tar -zxvf memcached-1.4.20.tar.gz
cd memcached-1.4.20
./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent/
make
make install
指定安装目录:--prefix=/usr/local/memcached
指定libevent目录:--with-libevent=/usr/local/libevent/
3. 启动memcached
进入安装目录
cd usr/local/memcached/bin/
执行如下命令
./memcached -d -m 100 -u root -l 10.17.0.50 -p 11211 -c 256 -P /tmp/memcached.pid
查看memcached进程
ps -ef|grep mmemcached
测试memcached
telnet 10.17.0.50 11211
stats
quit
4. 想开机自动启动
只需在/etc/rc.d/rc.local中加入一行,下面命令
/usr/local/memcached/bin/memcached -d -m 100 -p 11211 -u apache -c 256
上面有些东西可以参考一下:即,ip不指定时,默认是本机,用户:最好选择是:apache 或 deamon。这样,也就是属于哪个用户的服务,由哪个用户启动。
5. 安装memcached报错
1) 缺少GCC
报错信息:
[root@localhost memcached-1.4.20]# ./configure --prefix=/usr/lib64/memcached --with-libevent=/usr/lib
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/tmp/memcached-1.4.20':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
解决办法:
安装GCC软件套件
[root@localhost memcached-1.4.7]# yum install gcc
2) 缺少libevent
报错信息:
If it's already installed, specify its path using --with-libevent=/dir/
按照上面步骤安装libevent。