首页 > 代码库 > centos7 安装memcached扩展

centos7 安装memcached扩展

1,安装memcached

yum -y install memcached
/usr/bin/memcached -b -l 127.0.0.1 -p 11211 -m 150 -u root
查看memcached是否在运行:
[root@localhost /]# ps -ef | grep memcached
//或
[root@localhost /]# pstree -p | grep memcached

如果能够看到存在memcached进程,那就说明我们的 memcached 服务端已经安装成功了。

 

2,安装libmemached

安装目录为/usr/local/

wget https://launchpad.net/libmemcached/1.0/1.0.16/+download/libmemcached-1.0.16.tar.gz 
tar -zxvf libmemcached-1.0.16.tar.gz 
cd libmemcached-1.0.16 
./configure -prefix=/usr/local/libmemcached -with-memcached 
make && make install

3,下载memcache扩展包并安装

安装目录为/usr/local/

git clone git://github.com/php-memcached-dev/php-memcached.git
cd php-memcached/
#安装扩展
/usr/local/php/bin/phpize
./configure -enable-memcached -with-php-config=/usr/local/php/bin/php-config -with-zlib-dir -with-libmemcached-dir=/usr/local/libmemcached -prefix=/usr/local/php-memcached  --disable-memcached-sasl
make  -j4
make install

安装完毕后会提示扩展目录:/usr/local/php/lib/php/extensions/no-debug-zts-20151012/
编辑php.ini:

extension=/usr/local/php/lib/php/extensions/no-debug-zts-20151012/memcached.so

将其放入最后一行,重启php服务器(通过组件调用的,重启下web服务)
重新查看phpinfo:

centos7 安装memcached扩展