qiuxis 2016-10-28 21:17:49 8215次浏览 0条回复 1 1 0

1、linux 系统下安装 yum -y install memcached

[root ~]# yum search memcached
[root ~]# yum -y install memcached
[root ~]# memcached -h
memcached 1.4.15
...

安装成功

2、php7.0 memcached 扩展安装 扩展有两个 memcachememcached 我们选择安装 memcached 安装 memcached 扩展前需要安装 libmemcached

下载`libmemcached最新版本 暂时放于home路径下,编译安装

[root home]# wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
[root home]# cd /usr/local
[root local]# mkdir -p libmemcached
[root local]# cp /home/libmemcached-1.0.18.tar.gz ./
[root local]# tar zxf libmemcached-1.0.18.tar.gz
[root local]# cd libmemcached-1.0.18
[root libmemcached-1.0.18]#  ./configure --prefix=/usr/local/libmemcached --with-memcached
...
[root 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 libmemcached-1.0.18]# make install
...

下载memcached最新版本,编译安装

[root local]# cp /home/memcached-2.2.0.tgz ./
[root local]# tar zxf memcached-2.2.0.tgz
[root local]# cd memcached-2.2.0
[root 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 local]# git clone https://github.com/php-memcached-dev/php-memcached.git
正克隆到 'php-memcached'...
...

[root local]# cd php-memcached
[root php-memcached]# git checkout php7  //这一步很重要
分支 php7 设置为跟踪来自 origin 的远程分支 php7。
切换到一个新分支 'php7'
[root php-memcached]# /usr/bin/phpize
[root php-memcached]# ./configure --enable-memcached --with-php-config=/usr/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached  --disable-memcached-sasl
[root php-memcached]# make
...
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

[root php-memcached]# make install
Installing shared extensions:     /usr/lib64/php/modules/

[root 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

觉得很赞
    没有找到数据。
您需要登录后才可以回复。登录 | 立即注册