php的扩展memcache,不支持cas,所以我们要装memcached扩展,memcached扩展是基于libmemcached,所以要先安装libmemcached
一、下载软件
1、libmemcached下载地址:http://pecl.php.net/package/memcached
文件:memcached-2.2.0.tgz
2、php-memcached下载地址:https://launchpad.net/libmemcached/+download
文件:libmemcached-1.0.18.tar.gz
二、安装libmemcached
[root@vm15 local]# mkdir -p libmemcached
[root@vm15 local]# tar zxvf libmemcached-1.0.18.tar.gz
[root@vm15 local]# cd libmemcached-1.0.18
[root@vm15 libmemcached-1.0.18]# ./configure --prefix=/usr/local/libmemcached --with-memcached
[root@vm15 libmemcached-1.0.18]# make
[root@vm15 libmemcached-1.0.18]# make install
三、安装php-memcached
[root@vm15 local]# mkdir -p phpmemcached
[root@vm15 local]#tar zxvf memcached-2.2.0.tgz
[root@vm15 local]# cd memcached-2.2.0
[root@vm15 memcached-2.2.0]# /usr/local/php/bin/phpize
输出:
Configuring for:
PHP Api Version: 20131106
Zend Module Api No: 20131226
Zend Extension Api No: 220131226
[[email protected]]#./configure --enable-memcached --with-php-config=/usr/local/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached --disable-memcached --disable-memcached-sasl
[root@vm15 memcached-2.2.0]# make
[root@vm15 memcached-2.2.0]# make install
输出:
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20131226/
[root@vm15 memcached-2.2.0]# ll /usr/local/php/lib/php/extensions/no-debug-zts-20131226/
total 2140
-rwxr-xr-x. 1 root root 325608 Dec 30 15:59 memcached.so
-rwxr-xr-x. 1 root root 453766 Dec 30 17:44 memcache.so
-rwxr-xr-x. 1 root root 540834 Dec 19 15:38 opcache.so
-rwxr-xr-x. 1 root root 861055 Dec 30 16:47 redis.so
[root@vm15 memcached-2.2.0]# vi + /usr/local/php/lib/php.ini
找到这段,修改(将报错内容加入extension_dir):
extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20131226/"
然后下面加上:
extension=memcache.so
[Memcache]
memcache.allow_failover = 1
memcache.max_failover_attempts=20
memcache.chunk_size =8192
[root@vm15 memcached-2.2.0]#service php-fpm start
查看phpinfo可以看到支持了
ps:之前装了3.0.8,结果不显示,就换了上述版本,