1. 安装libevent 包:
yum -y install libevent libevent-devel
2. 下载安装包
memcache 扩展包, 下载地址: https://pecl.php.net/package/memcache libmemcached 包, 下载地址: https://launchpad.net/libmemcachedmemcached扩展包, 下载地址: https://pecl.php.net/package/memcached 找到PHP需要的文件路径:查找 php-config 文件的路径:find / -name 'php-config'查找 phpize 文件的路径: find / -name 'phpize'
3. 安装 memcache 扩展
tar -zxvf memcache-2.2.7.tgz -C /usr/local/src/cd /usr/local/src/memcache-2.2.7//usr/local/php/bin/phpize./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config --with-zlib-dirmake && make install
4. 安装 memcached 扩展
先安装 libmemcached: tar -zxvf libmemcached-1.0.18.tar.gz -C /usr/local/src/cd /usr/local/src/libmemcached-1.0.18/mkdir /usr/local/libmemcached./configure --prefix=/usr/local/libmemcachedmake && make install再安装 memcached 扩展tar -zxvf memcached-2.2.0.tgz -C /usr/local/src/cd /usr/local/src/memcached-2.2.0//usr/local/php/bin/phpize ./configure --with-php-config=/usr/local/php/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached --disable-memcached-saslmake && make install
5. 修改 PHP.ini 配置文件,增加扩展文件
memcache 扩展 和 memcached扩展安装完成后都能看到 .so 文件所在的路径,如下图:
修改 php.ini 文件增加扩展:
extension=/usr/local/php/lib/php/extensions/debug-non-zts-20131226/memcache.soextension=/usr/local/php/lib/php/extensions/debug-non-zts-20131226/memcached.so
最后记得 重启 PHP