1、安装libevent
memcached基于livevent的事件处理,所以首先安装libevent,用yum安装的话版本较低,所以编译安装
#tar zxvf libevent-1.4.13-stable.tar.gz
#cd libevent-1.4.13-stable
#./configure&& make&& make install
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2、安装memcached
#tarzxvf memcached-1.4.5.tar.gz
#./configure
#make && make install
安装完成后,memcached的默认目录为/usr/local/bin/memcached
添加链接库到ld.so.conf
#echo “/usr/local/lib”>>/etc/ld.so.conf
#ldconfig
启动memcached:
/usr/local/bin/memcached –m128 –p 11211 –d –u root –P /var/run/memcached.pid –vv
测试:telnet localhost 11211
关闭memcached: #kill` cat /var/run/memcached.pid`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3、安装memcache的php扩展
首先,打开phpize
#/usr/local/php5/bin/phpize
#tar zxvf memcache-2.2.5.tar.gz
#./configure –eanble-memcache–with-php-config=/usr/local/php5/bin/php-config
#make && makeinstall
然后根据提示,把生成的.so文件加入到php.ini里面
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
以上参见高翠峰的书