前言

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. 联想win8改win7

    知识点分析:目前联想出厂预装Windows 8的台式和一体机使用都是UEFI+GPT硬盘的组合,并且开启了安全启动,但是目前除Window 8以外的其他Windows系统均不支持这种模式,因此如果需要 ...

  2. blob转string,同步调用

    问题背景 通过接口下载文件的时候,后端设置的responseHeader content-disposition: attachment;filename=文件名.xlsx content-type: ...

  3. 2021-03-26:给定一个正整数N,表示有N份青草统一堆放在仓库里。有一只牛和一只羊,牛先吃,羊后吃,它俩轮流吃草。不管是牛还是羊,每一轮能吃的草量必须是:1,4,16,64…(4的某次方)。谁最先把草吃完,谁获胜。假设牛和羊都绝顶聪明,都想赢,都会做出理性的决定。根据唯一的参数N,返回谁会赢。

    2021-03-26:给定一个正整数N,表示有N份青草统一堆放在仓库里.有一只牛和一只羊,牛先吃,羊后吃,它俩轮流吃草.不管是牛还是羊,每一轮能吃的草量必须是:1,4,16,64-(4的某次方).谁最 ...

  4. MMCM and PLL Dynamic Reconfiguration

    Reconfiguration is performed through the DRP. The DRP provides access to the configuration bits that ...

  5. 【GiraKoo】Visual Studio开启Asan提示“LINK : fatal error LNK1104: cannot open file 'LIBVCASAN.lib'”

    [解决]Visual Studio开启Asan提示"LINK fatal error LNK1104 cannot open file 'LIBVCASAN.lib'" 环境 Vi ...

  6. CF1825C LuoTianyi and the Show

    传送门(luogu) 传送门(CF) 前言 我来水题解力 简化题意 \(n\) 个人,\(m\) 个座位,每个人落座的方法有三种: 坐最左边的人的左边,没人的话就做 \(m\) 号座位,若最左边的为 ...

  7. 非极大值抑制(NMS)算法详解

    NMS(non maximum suppression)即非极大值抑制,广泛应用于传统的特征提取和深度学习的目标检测算法中. NMS原理是通过筛选出局部极大值得到最优解. 在2维边缘提取中体现在提取边 ...

  8. Python Excel 操作 | xlrd+xlwt 模块笔记

    Python 的pandas模块使用xlrd作为读取 excel 文件的默认引擎.但是,xlrd在其最新版本(从 2.0.1 版本开始)中删除了对 xls 文件以外的任何文件的支持. xlsx fil ...

  9. awk 内置变量与自定义变量

    点击上方" 生信科技爱好者 ",马上关注 真爱,请置顶或星标 作者:ghostwu 原文:https://www.cnblogs.com/ghostwu/p/9085653.htm ...

  10. 如何解决安装完 webdriver-helper 但不可用的问题?

    一.问题分析 使用 selenium ,并使用自动化安装浏览器驱动的方法,下载 webdriver_helper 的官网:webdriver-helper · PyPI.下载完成后在终端使用 pip ...