Memcached用于动态Web应用以减轻数据库负载。它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提供动态、数据库驱动网站的速度。
部署步骤见下:
1.先安装libevent:
tar zxvf libevent-2.0.15-stable.tar.gz
cd libevent-2.0.15-stable
./configure --prefix=/usr/local/webserver/libevent-2.0.15
make && make install
2.安装memcached,同时需要在安装中指定libevent的安装位置
zxvf memcached-1.4.13.tar.gz
cd memcached-1.4.13
./configure --prefix=/usr/local/webserver/memcached-1.4.13 --with-libevent=/usr/local/webserver/libevent-2.0.15/
make && make install
启动Memcache的服务器端:
/usr/local/webserver/memcached-1.4.13/bin/memcached -d -m 64 -u root -l 192.168.0.200 -p 11211 -c 256 –P /tmp/memcached.pid
3.附:php的memcached扩展的安装:php有两个memcached扩展,一个是memcache,一个是memcached
1)安装libmemcached库
tar zxvf libmemcached-0.50.tar.tar
cd libmemcached-0.50
./configure --prefix=/usr/local/webserver/libmemcached --with-memcached
make
make install
2)安装php memcached扩展
zxvf memcached-1.0.2.tgz
cd memcached-1.0.2
/usr/local/webserver/php/bin/phpize
./configure --enable-memcached --with-php-config=/usr/local/webserver/php/bin/php-config --with-libmemcached-dir=/usr/local/webserver/libmemcached
make
make install
3)在php.ini里添加
vi /usr/local/webserver/php/etc/php.ini
extension_dir = "/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/"
extension = "memcache.so"
extension = "memcached.so"
再把服务重启一下
vi /etc/ld.so.conf
/usr/local/webserver/libevent-2.0.15/bin
/usr/local/webserver/libmemcached/bin