首先,安装PHP的Memcached扩展前,要先安装其所依赖的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 # make # make install
libmemcached安装完毕后,就可以开始安装Memcached扩展了,方法如下:
# wget https://pecl.php.net/get/memcached-2.2.0.tgz # tar zxvf ./memcached-2.2.0.tgz # cd memcached-2.2.0
解压缩后,我们需要先修改一下php_libmemcached_compat.h文件
将#include 的路径修改成#include </usr/local/include/libmemcached/memcached.h>然后再继续编译安装
# /usr/local/php/bin/phpize # ./configure --with-php-config=/usr/local/php/bin/php-config --disable-memcached-sasl # make # make install
最后,还要修改php.ini文件,加入extension=memcached.so并重启php-fpm即可。
阳光部落原创,更多内容请访问http://www.sunbloger.com/