linux企业实战----openresty


1. 什么是openresty

在这里插入图片描述
在这里插入图片描述

2. 操作

1.  tar zxf openresty-1.13.6.1.tar.gz 
2. cd openresty-1.13.6.1
  ./configure --prefix=/usr/local/openresty
  gmake && gmake install
3. nginx -s stop
4. cd /usr/local/openresty/nginx/conf/
  vim nginx.conf
  	user  nginx nginx;
http {
    include       mime.types;
    default_type  application/octet-stream;
    upstream memcache {
                server localhost:11211;
                keepalive 512;
        }
    location /memc{
                internal;  # 只接收内部访问,不接受外部http访问,比较安全。
                memc_connect_timeout 100ms;
                memc_send_timeout 100ms; # 后端服务器数据回传时间
                memc_read_timeout 100ms;   # 连接成功后,后端服务器响应时间
                set $memc_key $query_string;
                set $memc_exptime 300;
                memc_pass memcache;
        }
       location ~ \.php$ {
           set $key $uri$args;  
       # http的get方法表示get、put方法表示set
           srcache_fetch GET /memc $key;  # 请求php页面时,先回取memecache中找,如果没有找到,正常访问
           srcache_store PUT /memc $key; # 访问结束后将结果存到memcache,下次访问时直接从缓存中拿
           root           html;
           fastcgi_pass   127.0.0.1:9000;
           fastcgi_index  index.php;
           # fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
           include        fastcgi.conf;
       }
5. cp /usr/local/lnmp/nginx/html/index.php /usr/local/openresty/nginx/html/
6. cp /usr/local/lnmp/nginx/html/example.php /usr/local/openresty/nginx/html/
7. cd /usr/local/openresty/nginx/sbin/
  ./nginx

测试:

[kiosk@foundation60 images]$ ab -c 10 -n 5000 http://172.25.60.253/index.php
Concurrency Level:      10
Time taken for tests:   13.763 seconds
Complete requests:      5000
[kiosk@foundation60 images]$ ab -c 10 -n 5000 http://172.25.60.253/example.php
Concurrency Level:      10
Time taken for tests:   1.907 seconds
Complete requests:      5000

速度明显缩短

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值