lnmp----openresty外部存储

实验前提

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

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

猜你喜欢

转载自blog.csdn.net/weixin_43328213/article/details/87833907