作者:烨竹
1,安装memcached
yum -y install memcached
安装完以后执行如下操作:
chkconfig memcached on
/etc/init.d/memcached start
执行
netstat -tunlp | grep memcached
看到11211端口,说明memcached安装成功。
2,安装libmemached
wget https://launchpad.net/libmemcached/1.0/1.0.16/+download/libmemcached-1.0.16.tar.gz
tar -zxvf libmemcached-1.0.16.tar.gz
cd libmemcached-1.0.16
./configure -prefix=/usr/local/libmemcached -with-memcached
make && make install
3,下载memcache扩展包并安装
git clone git://github.com/php-memcached-dev/php-memcached.git
cd php-memcached/
安装扩展
查看phpize所在位置下面是我的位置
/usr/bin/phpize
./configure -enable-memcached -with-php-config=/usr/bin/php-config -with-zlib-dir -with-libmemcached-dir=/usr/local/libmemcached -prefix=/usr/local/phpmemcached --disable-memcached-sasl
也许会报错,不过根据报错提示可以解决问题
make -j4
make install
安装完毕后会提示扩展目录:/usr/lib64/php/modules/
查看php.ini位置:
php -i | grep php.ini
编辑php.ini:
添加:
extension=/usr/lib64/php/modules/memcached.so
将其放入最后一行,重启php服务器(通过组件调用的,重启下web服务)
重新查看phpinfo: