编译安装Memcached勾结php7

Memcached的官网http://memcached.org/](http://memcached.org/

一进去就可以看见 ”What is Memcached?“。英文的重要性。
Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载。

http://memcached.org/downloads 可以看见教你怎么安装。

Installation:Debian/Ubuntu: apt-get install libevent-dev Redhat/Centos: yum install libevent-devel

我的是centos6.5,所以就是,看下面。

//依赖:
yum install libevent-devel -y

wget http://memcached.org/files/memcached-1.4.31.tar.gz
tar -zxvf memcached-1.4.31.tar.gz
cd memcached-1.4.31

./configure –prefix=/usr/local/memcached
make && make install

//简单启动
./memcached -p 11211 -d -u root -m 1024 -c 1024 -l 127.0.0.1
-p 端口
-d 守护进程方式
-u root代表当前用户。最好不用root
-m 代表分配内存
-c 代表 最大连接上
-l 绑定地址。如果没有,谁都可以连

//连接和退出
telnet 127.0.0.1 11211
quit

//基本命令
set、add、replace、get、delete

//勾结php7有要麻烦点。
wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz //centos
tar -zxvf libmemcached-1.0.18.tar.gz
cd libmemcached-1.0.18

./configure

make && make install
ldconfig //最好执行一下 清除缓存

yum -y install git //安装git,没有git,就安装git
git clone https://github.com/php-memcached-dev/php-memcached.git 来下载

cd php-memcached //跑到里面去
git checkout php7 //进入php7分支
/usr/local/php/bin/phpize //就是phpize是用来扩展php扩展模块的,通过phpize可以建立php的外挂模块。

./configure –with-php-config=/usr/local/php/bin/php-config –disable-memcached-sasl

make && make install
//不出现什么错误 出现这条/usr/local/php/lib/php/extensions/no-debug-non-zts-20151012
//一般是完成了。

在php.ini后面加上 extension=”memcached.so”
echo ‘extension=”memcached.so”‘ >> /usr/local/php/lib/php.ini

//重启httpd会,phpinfo() 会出现 memcached

《编译安装Memcached勾结php7》

或者/usr/local/php/bin/php -m //可以看见memcached

《编译安装Memcached勾结php7》

    原文作者:黄123
    原文地址: https://www.jianshu.com/p/c7e59afabc28
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞