Linuxでmemcachedのインストール

1.memcachedのインストール
# wget http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz
# wget http://www.monkey.org/~provos/libevent-2.0.10-stable.tar.gz
# tar zxf libevent-2.0.10-stable.tar.gz
# cd libevent-2.0.10-stable
# ./configure –prefix=/usr
# make
# make install
# cd ../
# tar zxf memcached-1.4.5.tar.gz
# cd memcached-1.4.5
# ./configure –prefix=/usr/local/memcached –with-libevent=/usr
# make
# make install
# /usr/local/memcached/bin/memcached -d -m 10 -l 172.17.200.109 -p 11211 -u root -c 256 -P /usr/local/memcached/memcached.pid
2.memcacheを追加
# tar zxf memcache-2.2.6.tgz
# cd memcache-2.2.6
# /usr/local/php/bin/phpize
# ./configure –with-php-config=/usr/local/php/bin/php-config
# make
# make install
# ll
/usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613/memcache.so
php.iniの修正
前 extension_dir = “./”
後 extension_dir = “/usr/local/php/lib/php/extensions/no-debug-non-zts-2007xxxx/"
追加
extension=memcache.so
サーバが再起動

3.memcacheの検証
# pwd
/usr/local/nginx/html
# vi mem.php
<?php
$mem = new Memcache;
$mem->connect(“172.17.200.109", 11211);
$mem->set('key’,’this is a test page!’, 0, 60);
$val = $mem->get('key’);
echo $val;
?>

Linux

Posted by arkgame