准备memcache和memcached的软件包
1:解压:
[root@localhost memcache]# tar -zxvf memcached-1.4.13.tar.gz -C /usr/local/src/
[root@localhost memcache]# tar -zxvf memcache-2.2.5.tgz -C /usr/local/src/
2.1:安装缓存服务器
[root@localhost memcache]# cd /usr/local/src/memcached-1.4.13/
[root@localhost memcached-1.4.13]# ./configure --with-libevent=/usr/local/libevent
[root@localhost memcached-1.4.13]# make && make install
[root@localhost memcached-1.4.13]# cd /usr/local/bin
[root@localhost bin]# ll
总计 236
-rwxr-xr-x 1 root root 234942 09-05 17:17 memcached #服务工具
[root@localhost bin]# memcached -u nobody -d start #启动memcached服务
telnet IP(安装服务的地址) 11211(端口)
error .................出错没关系执行stats指令
stats
已经能够存储提取说明缓存服务器已经做成功了
2.2安装memcache客户端
[root@localhost memcache]# cd /usr/local/src/memcache-2.2.5/
[root@localhost memcache-2.2.5]# phpize
[root@localhost memcache-2.2.5]# ./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config
[root@localhost memcache-2.2.5]# make && make install
3:配置
/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/
#执行完成后make&& make install会提示你生成模块的路径编辑php初始化配置文件时要使用它
[root@localhost memcache-2.2.5]# vim /etc/php/php.ini #编辑php初始化配置文件
extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/memcache.so
#在任意一行插入调用模块的语句,注意等号前后要有空格
[root@localhost html]# vim index.php #在网站根目录下编辑index.php测试文件
<!DOCTYPE html><html><body><?php phpinfo(); ?></body></html> #调用phpinfo函数
重启php-fpm及nginx服务后测试