系列之三:php7.0下 安装 memcached 和 php扩展memcached [ 技术分享 ]
1、linux 系统下安装 yum -y install memcached
[root@localhost ~]# yum search memcached
[root@localhost ~]# yum -y install memcached
[root@localhost ~]# memcached -h
memcached 1.4.15
...
安装成功
2、php7.0 memcached 扩展安装
扩展有两个 memcache
和 memcached
我们选择安装 memcached
安装 memcached
扩展前需要安装 libmemcached
下载`libmemcached最新版本 暂时放于home路径下,编译安装
[root@localhost home]# wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
[root@localhost home]# cd /usr/local
[root@localhost local]# mkdir -p libmemcached
[root@localhost local]# cp /home/libmemcached-1.0.18.tar.gz ./
[root@localhost local]# tar zxf libmemcached-1.0.18.tar.gz
[root@localhost local]# cd libmemcached-1.0.18
[root@localhost libmemcached-1.0.18]# ./configure --prefix=/usr/local/libmemcached --with-memcached
...
[root@localhost libmemcached-1.0.18]# make
make -j3 all-am
make[1]: 进入目录“/usr/local/libmemcached-1.0.18”
CXX libhashkit/libhashkit_libhashkit_la-aes.lo
...
[root@localhost libmemcached-1.0.18]# make install
...
下载memcached最新版本,编译安装
[root@localhost local]# cp /home/memcached-2.2.0.tgz ./
[root@localhost local]# tar zxf memcached-2.2.0.tgz
[root@localhost local]# cd memcached-2.2.0
[root@localhost memcached-2.2.0]# ./configure --enable-memcached --with-php-config=/usr/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached
编译安装的时候出现问题,提示
/usr/local/memcached-2.2.0/php_memcached_private.h:44:40: fatal error: ext/standard/php_smart_str.h: No such file or directory
#include <ext/standard/php_smart_str.h>
^
compilation terminated.
make: *** [php_memcached.lo] 错误 1
解决办法,从github下载最新的 https://github.com/php-memcached-dev/php-memcached/tree/php7
[root@localhost local]# git clone https://github.com/php-memcached-dev/php-memcached.git
正克隆到 'php-memcached'...
...
[root@localhost local]# cd php-memcached
[root@localhost php-memcached]# git checkout php7 //这一步很重要
分支 php7 设置为跟踪来自 origin 的远程分支 php7。
切换到一个新分支 'php7'
[root@localhost php-memcached]# /usr/bin/phpize
[root@localhost php-memcached]# ./configure --enable-memcached --with-php-config=/usr/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached --disable-memcached-sasl
[root@localhost php-memcached]# make
...
----------------------------------------------------------------------
Build complete.
Don't forget to run 'make test'.
[root@localhost php-memcached]# make install
Installing shared extensions: /usr/lib64/php/modules/
[root@localhost php-memcached]# vi /etc/php.ini
...
[Memcached]
extension=memcached.so
...
启动 memcached :
[root@iZ23d ~]# systemctl start memcached.service
查看状态:
[root@iZ23d ~]# systemctl status memcached.service
至此memcached 和php扩展都安装成功!
系列之一:YII2 安装好 mongodb 扩展后调试 系列之二:YII2 安装好 mongodb 扩展后使用 ActiveRecord
共 0 条回复
没有找到数据。
qiuxis
注册时间:2016-10-31
最后登录:2017-10-25
在线时长:22小时6分
最后登录:2017-10-25
在线时长:22小时6分
- 粉丝21
- 金钱215
- 威望40
- 积分835