Memcached
想要安装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
phpize
./configure
make
make install
注意:
phpize是用来安装php扩展模块的,通过phpize可以建立php的外挂模块
当php编译完成后,php的bin目录下会有phpize这个脚本文件。在编译你要添加的扩展模块之前,执行以下phpize就可以了;当然也可以指定您的phpize
./configure是检测编译,生成makefile文件。 可以指定一些参数,详情看我另外一篇博客https://blog.youkuaiyun.com/yanyan42/article/details/80517567
如果./configure不存在,需要安装autoconf,然后重复phpize命令
安装好依赖库后,那么就可以正式安装memcached啦:
首先从github上克隆memcached后,需切换到PHP7分支,然后在进行make编译即可。
git clone -b php7 https://github.com/php-memcached-dev/php-memcached.git
cd php-memcached
phpize
./configure –disable-memcached-sasl
make
make install
Redis
同样的,redis的扩展安装与memcached类似,直接从github上克隆redis后,切换到PHP7分支,然后进行make编译即可。
git clone -b php7 https://github.com/phpredis/phpredis.gitcd phpredis
phpize
./configure
make
make install
memcache安装
wget https://github.com/websupport-sk/pecl-memcache/archive/php7.zip
unzip php7.zip
cd pecl-memcache-php7
phpize
./configure
make
make install
填写扩展
cd /usr/local/etc/php/7.2/conf.d
extension="/usr/local/Cellar/php/7.2.6/pecl/20170718/memcache.so"
启动扩展
安装扩展后,还需要编译php配置文件加载扩展才可以,再配置文件中添加:
extension=memcached.soextension=redis.so
重启php
brew services restart php
备注:重启NGINX:brew services restart nginx
参考:https://blog.youkuaiyun.com/houzhiwen_yy/article/details/69950836