php+memcache高速缓存

原文地址:https://blog.csdn.net/qq_33571752/article/details/86494667

#在lnmp基础上修改

依赖libevent程序库

cd lnmp/
tar zxf memcache-2.2.5.tgz
cd memcache-2.2.5

# 配置php环境
vim ~/.bash_profile
加入:/usr/local/lnmp/php/bin


source ~/.bash_profile

 

# 执行以下命令,然后编译
phpize

/configure


make && make install

 

# 修改该php的配置配置
vim /usr/local/lnmp/php/etc/php.ini

# 重新加载phph

/etc/init.d/php-fpm reload
php -m | grep memachecat
cat /etc/sysconfig/memcached

#下载memcached服务

yum install memcached -y
#启动连接memcached
/etc/init.d/memcached start

 

# 安装ipenresty,基于nginx和lua
tar zxf openresty-1.13.6.1.tar.gz
cd openresty-1.13.6.1
./configure
gmake && gmake install

 

#复制文件
cd /root/lnmp/memcache-2.2.5
cp memcache.php  example.php  /usr/local/openresty/nginx/html/

#修改如下

vim memcache.php
define('ADMIN_USERNAME','memcache');    // Admin Username
define('ADMIN_PASSWORD','redhat');      // Admin Password
$MEMCACHE_SERVERS[] = '172.25.42.1:11211'; // add more as an array
#$MEMCACHE_SERVERS[] = 'mymemcache-server2:11211'; // add more as an array

 

# 然后配置openresty下的nginx

vim /usr/local/openresty/nginx/conf/nginx.conf

 

启动openresty下的nginx

#浏览器登陆mencache统计页面,输入我们刚刚配置的用户和密码登陆

通过命令测试,两次访问时间相差几倍

ab -c 1 -n 1 http://172.25.70.1/example.php

posted @ 2019-05-28 16:13  php、凯  阅读(647)  评论(0编辑  收藏  举报