一、安装memcached
1.安装依赖包libevent
yum install libevent-devel -y
2.安装memcached
yum install memcached -y
3.配置memcached自启动
systemctl enable memcached
systemctl start memcached
二、安装php-memcahced拓展
1.安装依赖zlib和libmemcached
yum install zlib-devel -y
yum install libmemcached-devel -y
2.安装memcached拓展
在PECL(The PHP Extension Community Library)找到并安装php的memcached扩展。
例:
mkdir /usr/src/php -p
cd /usr/src/php
wget https://pecl.php.net/get/memcached -O memcached-2.2.0.tgz
tar xf memcached-2.2.0.tgz
cd memcached-2.2.0
phpize
# 我们在配置的添加一些新的功能,使其支持json和igbinary,有空可以研究一下
./configure –enable-memcached –with-php-config=/usr/bin/php-config
make
make install
# 注意最后的输出
#Installing shared extensions: /usr/lib64/php/modules/
3.增加拓展配置
vim /etc/php.d/memcached.ini
#增加一行
extension=memcached.so
保存退出
4.重启php进程,查看phpinfo
注:yum安装的都在默认位置