[关闭]
@cdmonkey 2026-07-16T03:54:42.000000Z 字数 4749 阅读 55

Nginx-1.30.4

Nginx


安装依赖包:

  1. yum install psmisc patch perl make zlib zlib-devel gcc gcc-c++ glibc perl-CPAN perl-IPC-Cmd perl-Time*

Lua

要使用 OpenResty 维护的 Lua 分支。

https://github.com/openresty/luajit2

若之前安装过 Nginx,最好把老的 lua 目录进行改名备份。

  1. cd /usr/local/nginx/
  2. mv lua lua_20260716

而后进行安装:

  1. tar zxvf luajit2-2.1-20260620.tar.gz
  2. cd luajit2-2.1-20260620
  3. make PREFIX=/usr/local/nginx/lua/luajit
  4. make install PREFIX=/usr/local/nginx/lua/luajit
  5. echo "export LUAJIT_LIB=/usr/local/nginx/lua/luajit/lib" >> /root/.bashrc
  6. echo "export LUAJIT_INC=/usr/local/nginx/lua/luajit/include/luajit-2.1" >> /root/.bashrc
  7. source /root/.bashrc

lua-resty-core

https://github.com/openresty/lua-resty-core

  1. tar zxvf lua-resty-core-0.1.32.tar.gz
  2. cd lua-resty-core-0.1.32
  3. mkdir -pv /usr/local/nginx/lua/lualib/resty
  4. cp -r lib/resty/* /usr/local/nginx/lua/lualib/resty/

lua-resty-lrucache

https://github.com/openresty/lua-resty-lrucache

  1. tar zxvf lua-resty-lrucache-0.15.tar.gz
  2. cd lua-resty-lrucache-0.15
  3. cp -r lib/resty/* /usr/local/nginx/lua/lualib/resty/

nginx_upstream_check_module

https://github.com/mofantor/nginx_upstream_check_module

  1. unzip nginx_upstream_check_module-master.zip
  2. cd nginx-1.30.4
  3. patch -p1 < ../nginx_upstream_check_module-master/check_1.30.0+.patch
  4. # out:
  5. patching file src/http/modules/ngx_http_upstream_hash_module.c
  6. patching file src/http/modules/ngx_http_upstream_ip_hash_module.c
  7. patching file src/http/modules/ngx_http_upstream_least_conn_module.c
  8. patching file src/http/modules/ngx_http_upstream_random_module.c
  9. patching file src/http/ngx_http_upstream_round_robin.c
  10. patching file src/http/ngx_http_upstream_round_robin.h

Nginx

注意:resty-core 要求 lua-nginx-module 版本恰好等于指定值,二者必须来自同一发布配对。

lua-resty-core 要求的 lua-nginx-module(精确) 状态
v0.1.32 0.10.2910029 ✅ 最新稳定版
v0.1.33rc1 / rc2 0.10.30(10030 RC(候选版)
v0.1.34rc2 / rc3 0.10.31(10031 RC(候选版)
v0.1.35rc1 0.10.32(10032 RC(候选版)

这里就采用表格第一行的对应版本。

  1. ./configure \
  2. --prefix=/usr/local/nginx \
  3. --user=app \
  4. --group=app \
  5. --with-pcre=/root/tools/pcre2-10.47 \
  6. --with-openssl=/root/tools/openssl-3.5.6 \
  7. --with-http_sub_module \
  8. --with-http_ssl_module \
  9. --with-http_gunzip_module \
  10. --with-http_gzip_static_module \
  11. --with-http_stub_status_module \
  12. --with-http_auth_request_module \
  13. --with-http_random_index_module \
  14. --with-http_realip_module \
  15. --with-ld-opt="-Wl,-rpath,/usr/local/nginx/lua/luajit/lib" \
  16. --add-module=/root/tools/nginx_upstream_check_module-master \
  17. --add-module=/root/tools/ngx_devel_kit-0.3.4 \
  18. --add-module=/root/tools/lua-nginx-module-0.10.29R2 \
  19. --add-module=/root/tools/ngx_dynamic_upstream-master \
  20. --add-module=/root/tools/nginx-module-vts-0.2.5 \
  21. --http-client-body-temp-path=/usr/local/nginx/temp/client_body_temp \
  22. --http-proxy-temp-path=/usr/local/nginx/temp/proxy_temp \
  23. --http-fastcgi-temp-path=/usr/local/nginx/temp/fastcgi_temp \
  24. --http-uwsgi-temp-path=/usr/local/nginx/temp/uwsgi_temp \
  25. --http-scgi-temp-path=/usr/local/nginx/temp/scgi_temp \
  26. --with-stream \
  27. --with-stream_ssl_module \
  28. --with-stream_ssl_preread_module

Old Document

以下是之前的老文档,仅供参考。

  1. useradd nginx -s /sbin/nologin -M
  2. yum install unzip patch glibc zlib zlib-devel gcc gcc-c++ make perl perl-IPC-Cmd perl-Data-Dumper

解压并编译安装:

  1. luajit2-2.1-20230410.1.tar.gz - make && make install PREFIX=/usr/local/nginx/lua/luajit
  2. lua-resty-core-0.1.28.tar.gz - make install PREFIX=/usr/local/nginx/lua
  3. lua-resty-lrucache-0.13.tar.gz - make install PREFIX=/usr/local/nginx/lua

解压下列安装包:

  1. nginx_upstream_check_module-master.zip
  2. ngx_dynamic_upstream-master.zip
  3. lua-nginx-module-0.10.26.tar.gz
  4. nginx-module-vts-0.2.2.tar.gz
  5. ngx_devel_kit-0.3.3.tar.gz
  6. openssl-3.3.1.tar.gz
  7. pcre-8.45.zip

/root/.bashrc 配置环境变量:

  1. export LUAJIT_LIB=/usr/local/nginx/lua/luajit/lib
  2. export LUAJIT_INC=/usr/local/nginx/lua/luajit/include/luajit-2.1
  1. ./configure \
  2. --prefix=/usr/local/nginx \
  3. --user=nginx \
  4. --group=nginx \
  5. --with-openssl=/root/tools/nginx-update-1.26.2/openssl-3.3.1 \
  6. --with-http_ssl_module \
  7. --with-http_gunzip_module \
  8. --with-http_gzip_static_module \
  9. --with-http_stub_status_module \
  10. --with-pcre=/root/tools/nginx-update-1.26.2/pcre-8.45 \
  11. --with-http_realip_module \
  12. --with-ld-opt="-Wl,-rpath,/usr/local/nginx/lua/luajit/lib" \
  13. --add-module=/root/tools/nginx-update-1.26.2/nginx_upstream_check_module-master \
  14. --add-module=/root/tools/nginx-update-1.26.2/ngx_dynamic_upstream-master \
  15. --add-module=/root/tools/nginx-update-1.26.2/nginx-module-vts-0.2.2 \
  16. --add-module=/root/tools/nginx-update-1.26.2/ngx_devel_kit-0.3.3 \
  17. --add-module=/root/tools/nginx-update-1.26.2/lua-nginx-module-0.10.26 \
  18. --http-client-body-temp-path=/usr/local/nginx/temp/client_body_temp \
  19. --http-proxy-temp-path=/usr/local/nginx/temp/proxy_temp \
  20. --http-fastcgi-temp-path=/usr/local/nginx/temp/fastcgi_temp \
  21. --http-uwsgi-temp-path=/usr/local/nginx/temp/uwsgi_temp \
  22. --http-scgi-temp-path=/usr/local/nginx/temp/scgi_temp \
  23. --with-stream \
  24. --with-stream_ssl_preread_module

主配置文件增加一行:

  1. lua_package_path '/usr/local/nginx/lua/lib/lua/?.lua;;';

Github:

https://github.com/vision5/ngx_devel_kit
https://github.com/vozlt/nginx-module-vts
https://github.com/openresty/lua-nginx-module

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注