lnmp----openresty外部存储

79 篇文章 0 订阅

实验前提

openresty自带nginx,所以,不能有其他nginx在运行。

[root@server1 conf]# nginx -s stop

实验过程

[root@server1 ~]# tar zxf openresty-1.13.6.1.tar.gz (解压openresty包)
[root@server1 openresty-1.13.6.1]# cd openresty-1.13.6.1
[root@server1 openresty-1.13.6.1]# ./configure (编译)
[root@server1 openresty-1.13.6.1]# gmake && gmake install(安装)

编辑一个php动态网页。
[root@server1 html]# vim  /usr/local/lnmp/nginx/html/index.php 
	<?php
	phpinfo()
	?>	

编辑openresty自带的nginx的配置文件,如果系统有其他nginx要注意目录名称。

[root@server1 html]# vim /usr/local/openresty/nginx/conf/nginx.conf
17 http {
 18         upstream memcache {
 19                 server localhost:11211;
 20                 keepalive 512;
 21         }
 22         include       mime.types;
 23     default_type  application/octet-stream;

 53         location /memc {
 54            internal;
 55            memc_connect_timeout 100ms;
 56            memc_send_timeout 100ms;
 57            memc_read_timeout 100ms;
 58            set $memc_key $query_string;
 59            set $memc_exptime 300;
 60            memc_pass memcache;
 61         }


 77         location ~ \.php$ {
 78             set $key $uri$args;
 79             srcache_fetch GET /memc $key;
 80             srcache_store PUT /memc $key;
 81             root           html;
 82             fastcgi_pass   127.0.0.1:9000;
 83             fastcgi_index  index.php;
 84             #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_    name;
 85             include        fastcgi.conf;
 86	 }

打开nginx:

[root@server1 sbin]# pwd
/usr/local/openresty/nginx/sbin
[root@server1 sbin]# ./nginx 

查看服务端口号:

[root@server1 sbin]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 0.0.0.0:11211               0.0.0.0:*                   LISTEN      28145/memcached     
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      4241/nginx          

将博客memcache的测试网页从/usr/local/lnmp/nginx/html下复制到/usr/local/openresty/nginx/html下。


通过ab模拟服务器访问数据,检测速度,在memcache上再加一次外部缓存后,速度比之前的更快,并且没有失败的请求。(可与memcache的数据做比较)

[root@server1 sbin]#  ab -c 10 -n 5000 http://172.25.55.1/index.php
	Time taken for tests:   1.158 seconds
	Complete requests:      5000
	Failed requests:        0
	Write errors:           0


[root@server1 sbin]#  ab -c 10 -n 5000 http://172.25.55.1/example.php
	Time taken for tests:   0.594 seconds
	Complete requests:      5000
	Failed requests:        0
	Write errors:           0

访问网页:
在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值