1、先下载libmemcached:
yum install cyrus-sasl-devel #必须先安装再编译libmemcached,不然memcached编译会提示没有sasl
tar zxvf libmemcached-1.0.18.tar.gz
cd libmemcached-1.0.18
./configure --prefix=/usr/local/libmemcached --with-memcached
make
make install
2、安装php-memcached
tar zxvf memcached-2.2.0.tgz (再高的版本需要PHP7)
cd memcached-2.2.0
/usr/local/php/bin/phpize
./configure --enable-memcached --with-php-config=/usr/local/php/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached
make
make install
3、添加扩展
vim /usr/local/php/etc/php.ini
extension=memcached.so
4、重启php-fpm
service php-fpm restart
5、检测
php -m