服务端安装memcache

2016/11/23 Linux

php开发环境已经搭建完毕, 然后再给php安装memcache的扩展. 主要用的是php自带的phpize命令.

服务端安装memcache

##获取源码包

[[email protected] src]# wget http://memcached.org/files/memcached-1.4.33.tar.gz

##解压源码包

[[email protected] src]# tar zxvf memcached-1.4.33.tar.gz 

##添加安装目录

[[email protected] memcached-1.4.33]# mkdir /usr/local/memcache

##变以前配置

[[email protected] memcached-1.4.33]# ./configure --prefix=/usr/local/memcache

报错:

...
...
checking for library containing gethostbyname... none required
checking for libevent directory... configure: error: libevent is required.  You can get it from http://www.monkey.org/~provos/libevent/

      If it's already installed, specify its path using --with-libevent=/dir/

[[email protected] memcached-1.4.33]# 

错误原因:缺少依赖包 libevent 下载libevent, 下载且安装

[[email protected] memcached-1.4.33]# wget -P /usr/local/src/ https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz
[[email protected] memcache]# cd /usr/local/src
[[email protected] src]# tar zxvf libevent-2.0.22-stable.tar.gz 
[[email protected] src]# cd libevent-2.0.22-stable
[[email protected] libevent-2.0.22-stable]# mkdir /usr/local/libevent
[[email protected] libevent]# cd /usr/local/src
[[email protected] src]# cd memcached-1.4.33
[[email protected] memcached-1.4.33]# ./configure --prefix=/usr/local/memcache/ --with-libevent=/usr/local/libevent/

服务端的memcache安装完毕

[[email protected] memcached-1.4.33]# wget -P /usr/local/src/ http://pecl.php.net/get/memcache-3.0.8.tgz
[[email protected] memcached-1.4.33]# cd /usr/local/src
[[email protected] src]# ls
libevent-2.0.22-stable  libevent-2.0.22-stable.tar.gz  lnmp.source  memcache-3.0.8.tgz  memcached-1.4.33  memcached-1.4.33.tar.gz
[[email protected] src]# 
[[email protected] src]# tar zxvf memcache-3.0.8.tgz
[[email protected] memcache-3.0.8]# /usr/local/php5/bin/phpize 
Configuring for:
PHP Api Version:         20121113
Zend Module Api No:      20121212
Zend Extension Api No:   220121212
[[email protected] memcache-3.0.8]# ./configure --with-php-config=/usr/local/php/bin/php-config --enable-memcache

-w676

##重启nginx, phpinfo没有memcache, 但是查看php模块有.

所以重启php-fpm试试, 结果就有了.

-w737

-w414

-w475

Search

    Post Directory