0x1
# luajit下载
https://github.com/openresty/luajit2
# lua nginx下载
https://github.com/openresty/lua-nginx-module
# ngx_devel_kit 下载
0x2
make && make install PREFIX=/usr/local/luajit-2.1 && ln -s /usr/local/luajit-2.1 /usr/local/luajit
# tell nginx's build system where to find LuaJIT 2.0:
export LUAJIT_LIB=/usr/local/luajit/lib
export LUAJIT_INC=/usr/local/luajit/include/luajit-2.0
# tell nginx's build system where to find LuaJIT 2.1:
# 否则 nginx 会报错 ./configure: error: ngx_http_lua_module requires the Lua library
export LUAJIT_LIB=/usr/local/luajit/lib
export LUAJIT_INC=/usr/local/luajit/include/luajit-2.1
./configure --prefix=/opt/nginx \
--with-ld-opt="-Wl,-rpath,/path/to/luajit/lib" \
--add-module=/path/to/ngx_devel_kit \
--add-module=/path/to/lua-nginx-module
# lua下载到本地
./configure --prefix=/usr/local/tengine --add-module=modules/ngx_http_upstream_session_sticky_module/ --add-module=modules/ngx_http_upstream_check_module/ --with-stream --with-stream_realip_module --with-http_sub_module --add-module=modules/ngx_http_substitutions_filter_module/ --with-http_gunzip_module --with-ld-opt=-ljemalloc --with-ld-opt="-Wl,-rpath,/usr/local/luajit/lib" --add-module=/path/to/lua-nginx-module
0x3
编译到nginx遇到的几个问题
- 高版本lua模块在nginx上编译后启动有问题,所以使用回低版本: v0.10.14
- tengine编译后使用set_by_lua_file报错如下:
unknown directive "set_by_lua_file"
但是content_by_lua没有问题,说明lua安装是成功的,经过排查是ngx_devel_kit没有编译导致
./configure --prefix=/usr/local/tengine --add-module=modules/ngx_http_upstream_session_sticky_module/ --add-module=modules/ngx_http_upstream_check_module/ --with-stream --with-stream_realip_module --with-http_sub_module --add-module=modules/ngx_http_substitutions_filter_module/ --with-http_gunzip_module --with-ld-opt=-ljemalloc --with-ld-opt="-Wl,-rpath,/usr/local/luajit/lib" --add-module=./lua-nginx-module-0.10.14/ --add-module=./ngx_devel_kit-0.3.1/
- 20230824 在 tengine-3.0.0上编译入之前下载的lua-nginx,报错如下:
./lua-nginx-module-0.10.14//src/ngx_http_lua_headers_in.c:162:18: error: ‘ngx_http_headers_in_t’ has no member named ‘cookies’
需要去openresty下载新版本 lua-nginx
https://github.com/openresty/lua-nginx-module