一.OpenResty安装和测试
官方网站:https://openresty.org/cn/
<标题>OpenResty ?
头>OpenResty ?,是一个基于,Nginx 与Lua的高性能网络平台,其内部集成了大量精良的Lua库,第三方模块以及大多数的依赖项。用于方便地搭建能够处理超高并发,扩展性极高的动态网络应用,Web服务和动态网关。
OpenResty ?,通过汇聚各种设计精良的,Nginx 模块(主要由OpenResty团队自主开发),从而将,Nginx 有效地变成一个强大的通用网络应用平台。这样,网页开发人员和系统工程师可以使用Lua脚本语言调动,Nginx 支持的各种C以及Lua模块,快速构造出足以胜任10 k乃至1000 k以上单机并发连接的高性能网络应用系统。
OpenResty ?,的目标是让你的Web服务直接跑在,Nginx 服务内部,充分利用,Nginx 的非阻塞I/O模型,不仅仅对HTTP客户端请求,甚至于对远程后端诸如MySQL、PostgreSQL, Memcached以及复述等都进行一致的高性能响应。
Lua学习:http://blog.jobbole.com/70480/
1。安装OpenResty:
# yum安装- y readline-devel pcre-devel openssl-devel
# cd/usr/local/src
下载并编译安装OpenResty # wget https://openresty.org/download/ngx_openresty-1.9.3.2.tar.gz
#焦油zxf ngx_openresty-1.9.3.2.tar。广州
# cd ngx_openresty-1.9.3.2
# ./configure——prefix=/usr/地方/ngx_openresty-1.9.3.2 \
——with-luajit with-http_stub_status_module \
——with-pcre with-pcre-jit
# gmake,,gmake安装
# ln - s/usr/local/openresty-1.9.3.2//usr/local/openresty
#报错提醒:
在。/配置时的报错:
/usr/bin/env: perl:没有这样的文件或目录
出现这种错误可能是没有安装perl,解决yum安装perl - y
[root@localhost ngx_openresty-1.9.3.2] #,。/configure ——prefix=/usr/地方/openresty-1.9.3.2 \——with-luajit ——with-http_stub_status_module \——with-pcre ——with-pcre-jit 平台:linux (linux) cp -rp 包/构建 cd 构建 luajit cd 2.1 - 20151028 停下来# 39;t exec “cc":, No such file 或是directory at 。/configure line 588。 gmake TARGET_STRIP=@: CCDEBUG=-g CC=cc 前缀=/usr/地方/openresty-1.9.3.2/luajit====,Building LuaJIT  2.1.0-beta1 ====gmake -C  src gmake [1]: cc: Command not 发现 gmake [1]: Entering directory ,“/usr/地方/ngx_openresty-1.9.3.2/构建/luajit - 2.1 - 20151028/src # 39; gmake [1]: cc: Command not 发现 gmake [1]: cc: Command not 发现 gmake [1]: cc: Command not 发现 gmake [1]: cc: Command not 发现 gmake [1]: cc: Command not 发现 Makefile: 237: * * *, Unsupported target 架构只停止。 gmake [1]: Leaving directory ,“/usr/地方/ngx_openresty-1.9.3.2/构建/luajit - 2.1 - 20151028/src # 39; gmake: * * *,(默认),Error 2 错误:,failed 用run 命令:,gmake TARGET_STRIP=@:, CCDEBUG=-g CC=cc PREFIX=/usr/地方/openresty-1.9.3.2/luajit
解决:
yum安装* gcc * - y
2。测试openresty安装:
vim/usr/local/openresty/nginx/conf/nginx.参看
,,,,,,,,,的位置/hello { ,,,,,,,,,,,,default_type text/html; ,,,,,,,,,,,,content_by_lua_block { ,,,,,,,,,,,,ngx.say (“HelloWorld") ,,,,,,,,,,,}
3。启动openresty并测试:
/usr/地方/openresty/nginx/sbin/nginx -t
/usr/地方/openresty/nginx/sbin/nginx
[root@localhost ~] #, curl http://10.0.0.50/hello HelloWorld
4。性能测试
- 1。安装压力测试工具
[root@localhost ~] #, yum install httpd-tools - y
, 2。测试
[root@localhost ~] #, ab -c10 -n5000 http://10.0.0.50/hello 却,能够is ApacheBench, Version 2.3, & lt;修订:美元,1430300,美元比; null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null使用Nginx + Lua实现的WAF网站防护功能