Openresty

一:简介

 OpenResty(又称:ngx_openresty) 是一个基于 NGINX 的可伸缩的 Web 平台,由中国人章亦春发起,提供了很多高质量的第三方模块。

OpenResty 是一个强大的 Web 应用服务器,Web 开发人员可以使用 Lua 脚本语言调动 Nginx 支持的各种 C 以及 Lua 模块,更主要的是在性能方面,OpenResty可以 快速构造出足以胜任 10K 以上并发连接响应的超高性能 Web 应用系统。

360,UPYUN,阿里云,新浪,腾讯网,去哪儿网,酷狗音乐等都是 OpenResty 的深度用户。

二:安装依赖包

#yum install readline-devel pcre-devel openssl-devel gcc

三:安装openresty

3.1下载openresty源码

#wget https://openresty.org/download/openresty-1.9.7.4.tar.gz

3.2解压安装包

#tar xzvf openresty-1.9.7.4.tar.gz

 3.3配置编译选项,可以根据你的实际情况增加、减少相应的模块

1#cd openresty-1.9.7.4/ 2#./configure --prefix=/opt/openresty --with-luajit --without-http_redis2_module --with-http_iconv_module

3.4编译安装

1# make 2#make install

四:使用

14.1修改配置文件如下 2 3# cat /opt/openresty/nginx/conf/nginx.conf 4worker_processes 1; 5error_log logs/error.log info; 6 7events { 8 worker_connections 1024; 9} 10 11http { 12 server { 13 listen 8003; 14 15 location / { 16 content_by_lua 'ngx.say("hello world.")'; 17 } 18 } 19}

4.2启动nginx

#/opt/openresty/nginx/sbin/nginx

4.3使用nginx

1# curl http://127.0.0.1:8003/ 2hello world.

五:性能测试

5.1安装压力测试工具

#yum install httpd-tools

5.2测试

1# ab -c10 -n50000 http://localhost:8003/ 2This is ApacheBench, Version 2.3 <$Revision: 1430300 $> 3Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ 4Licensed to The Apache Software Foundation, http://www.apache.org/ 5 6Benchmarking localhost (be patient) 7Completed 5000 requests 8Completed 10000 requests 9Completed 15000 requests 10Completed 20000 requests 11Completed 25000 requests 12Completed 30000 requests 13Completed 35000 requests 14Completed 40000 requests 15Completed 45000 requests 16Completed 50000 requests 17Finished 50000 requests 18 19 20Server Software: openresty/1.9.7.4 21Server Hostname: localhost 22Server Port: 8003 23 24Document Path: / 25Document Length: 13 bytes 26 27Concurrency Level: 10 28Time taken for tests: 7.857 seconds 29Complete requests: 50000 30Failed requests: 0 31Write errors: 0 32Total transferred: 8050000 bytes 33HTML transferred: 650000 bytes 34Requests per second: 6363.75 [#/sec] (mean) 35Time per request: 1.571 [ms] (mean) 36Time per request: 0.157 [ms] (mean, across all concurrent requests) 37Transfer rate: 1000.55 [Kbytes/sec] received 38 39Connection Times (ms) 40 min mean[+/-sd] median max 41Connect: 0 0 0.2 0 1 42Processing: 1 1 0.2 1 4 43Waiting: 1 1 0.1 1 3 44Total: 1 2 0.1 2 4 45 46Percentage of the requests served within a certain time (ms) 47 50% 2 48 66% 2 49 75% 2 50 80% 2 51 90% 2 52 95% 2 53 98% 2 54 99% 2 55 100% 4 (longest request)

六:nginx服务相关命令

6.1启动

#/opt/openresty/nginx/sbin/nginx

6.2停止

#/opt/openresty/nginx/sbin/nginx -s stop

6.3重启

#/opt/openresty/nginx/sbin/nginx -s reload

6.4检验nginx配置是否正确

# /opt/openresty/nginx/sbin/nginx -t
点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

OpenResty入门

本文已收录https://github.com/lkxiaolou/lkxiaolou欢迎star。OpenResty介绍OpenResty通过汇聚各种设计精良的Nginx模块(主要由OpenResty团队自主开发),从而将Nginx有效地变成一个强大的通用Web应用平台。这样,Web开发人员和系统工程师可以使用Lua脚本语言调动