安装memcached扩展

1、安装依赖库 libmemcached

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

2、安装memcached模块

wget https://github.com/php-memcached-dev/php-memcached/archive/php7.zip
unzip php7.zip
cd php-memcached-php7/
/application/php/bin/phpize 
./configure \
--with-php-config=/application/php/bin/php-config \
--with-libmemcached-dir=/usr/local/libmemcached \
--disable-memcached-sasl
make
make install
  Installing shared extensions:     /application/php-7.1.7/lib/php/extensions/no-debug-non-zts-20160303/

3、检查模块是否存在

cd /application/php-7.1.7/lib/php/extensions/no-debug-non-zts-20160303/
ls memcached.so 
  memcached.so

4、修改 php.ini

vim /application/php/lib/php.ini
 ...
 extension=memcached.so
 ...

5、重启php-fpm

6、测试连接memecached服务器

<?php
#/application/nginx/html/c.php
$memcache = new Memcached();
$memcache->addServer('192.168.88.2', 11211);
$memcache->set('key', 'mm');
$get = $memcache->get('key');
echo $get;
$memcache->quit();
?>

  

 

posted @ 2017-11-05 17:32  sellsa  阅读(281)  评论(0编辑  收藏  举报