centos7中php-fpm添加memcache模块

安装依赖库

1
2
3
4
5
6
7
8
9
10
11
#libevent类库
wget   http://www.monkey.org/~provos/libevent-2.0.12-stable.tar.gz
tar xzfv  libevent-2.0.12-stable.tar.gz
cd libevent-2.0.12-stable
./configure
make
make install
#zlib
yum install zlib-devel
#gcc
yum install gcc

安装Memcached,centos7下有一键安装包,我就用这个了

1
2
3
4
yum install memcached
#启动和添加开启启动
systemctl enable memcached
systemctl start memcached

php的一定需要一下这几个,我都是用centos7的直接安装的

1
yum install php php-fpm php-devel

接下来主要是将memcache加入到php中

1
2
3
4
5
6
7
8
9
10
wget http://pecl.php.net/get/memcache-2.2.4.tgz
tar zxvf memcache-2.2.4.tgz
cd memcache-2.2.4
#然后找出phpize
whereis phpize
#我的是在/usr/bin/phpize
/usr/bin/phpize
./configure --with-php-config=/usr/bin/php-config
make
make install

然后在php.ini末尾文件添加

1
2
3
4
[memcached]
extension=memcache.so
#重启php-fpm
systemctl restart php-fpm

然后要在phpinfo里面或者探针里面见到有memcache才行

添加评论