ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

[nginx]编译安装openresty

2022-09-04 15:01:24  阅读:296  来源: 互联网

标签:http 编译 -- dynamic module nginx dev openresty


前言

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的内容处理阶段生成数据

参考

标签:http,编译,--,dynamic,module,nginx,dev,openresty
来源: https://www.cnblogs.com/XY-Heruo/p/16655116.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有