前提需要的依赖包安装
yum install php-devel php-common php-cli cyrus-sasl-plain cyrus-sasl cyrus-sasl-devel cyrus-sasl-lib zlib-devel -y
首先安装libmemcached
wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz tar zxvf libmemcached-1.0.18.tar.gz cd libmemcached-1.0.18 ./configure --prefix=/usr/local/libmemcached --enable-sasl make make install
接着我们安装memcached源码包
wget http://pecl.php.net/get/memcached-2.2.0.tgz tar zxvf memcached-2.2.0.tgz cd memcached-2.2.0 phpize(如果系统中有两套PHP环境,需绝对路径调用该命令/usr/bin/phpize,该路径为使用云数据库Memcache的PHP环境路径) ./configure --with-php-config=/usr/local/php5/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached --enable-memcached-sasl(注意这个参数) make make install
最后去php.ini文件内添加
extension=memcache.so