php+memcache高速缓存

#在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

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值