PHP添加扩展模块及openresty(缓存前移)

82 篇文章 3 订阅

Memcached

Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载。它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态、数据 库驱动网站的速度。Memcached基于一个存储键/值对的hashmap。其守护进程(daemon )是用C写的,但是客户端可以用任何语言来编写,并通过memcached协议与守护进程通信

一·php模块扩展

下载 memcache-2.2.5.tgz

[root@server1 ~]# tar zxf memcache-2.2.5.tgz    ##解压
[root@server1 ~]# cd memcache-2.2.5
[root@server1 memcache-2.2.5]# cd /usr/local/lnmp/php/bin/
[root@server1 bin]# pwd
/usr/local/lnmp/php/bin
[root@server1 bin]# cd
[root@server1 ~]# vim .bash_profile    
##增加路径,写入:
     10 PATH=$PATH:$HOME/bin:/usr/local/lnmp/mysql/bin:/usr/local/lnmp/nginx/sbin:/usr/local/lnmp/php/bin
[root@server1 ~]# source .bash_profile
[root@server1 ~]# cd memcache-2.2.5
[root@server1 memcache-2.2.5]# phpize 

编译三部曲:

[root@server1 memcache-2.2.5]# ./configure 
[root@server1 memcache-2.2.5]# make
[root@server1 memcache-2.2.5]# make install 

修改配置文件:

[root@server1 memcache-2.2.5]# cd /usr/local/
[root@server1 local]# cd lnmp/php/etc/
[root@server1 etc]# vim php.ini 
编辑:
     873 extension=memcache.so
[root@server1 etc]# /etc/init.d/php-fpm reload
Reload service php-fpm  done
[root@server1 etc]# php -m |grep memcache
memcache
[root@server1 etc]# cd
[root@server1 ~]# cd memcache-2.2.5
[root@server1 memcache-2.2.5]# cp memcache.php example.php /usr/local/lnmp/nginx/html/
[root@server1 memcache-2.2.5]# yum install memcached -y
[root@server1 memcache-2.2.5]# /etc/init.d/memcached start
[root@server1 memcache-2.2.5]# netstat -antlp |grep :11211
[root@server1 html]# vim memcache.php 

 

在 memcache.php 文件
这里写图片描述
网页访问:

这里写图片描述
这里写图片描述
这里写图片描述

物理机做压力测试:

ab -c 10 -n 1000 http://172.25.41.1/memcache.php

ab -c 10 -n 1000 http://172.25.41.1/example.php

二·缓存前移

安装包: openresty-1.13.6.1.tar.gz

[root@server1 ~]# tar zxf openresty-1.13.6.1.tar.gz 
[root@server1 ~]# cd openresty-1.13.6.1

编译三部曲:

[root@server1 openresty-1.13.6.1]# ./configure --prefix=/usr/local/lnmp/openresty --with-http_ssl_module --with-http_stub_status_module --user=nginx --group=nginx --with-threads --with-file-aio
[root@server1 openresty-1.13.6.1]# gmake
[root@server1 openresty-1.13.6.1]# gmake   install

配置文件:

[root@server1 conf]# vim nginx.conf
[root@server1 conf]# /usr/local/lnmp/openresty/nginx/sbin/nginx -t   ##检测
[root@server1 conf]# /usr/local/lnmp/openresty/nginx/sbin/nginx   ##打开


 

网页访问:

这里写图片描述

物理机压力测试:

ab  -c  10  -n  1000  http://172.25.41.1/index.php

ab  -c  10 -n 1000 http://172.25.41.1/example.php

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值