安装luajit2
cd /www/mod wget https://github.com/openresty/luajit2/archive/refs/tags/v2.1-20220915.tar.gz tar xf v2.1-20220915.tar.gz cd /www/mod/luajit2-2.1-20220915 make && make install
拉取lua-nginx-module, lua-resty-core, lua-resty-lrucache
git clone https://github.com/openresty/lua-nginx-module
git clone https://github.com/openresty/lua-resty-core cd lua-resty-core make install PREFIX=/www/server/nginx
git clone https://github.com/openresty/lua-resty-lrucache cd lua-resty-lrucache make install PREFIX=/www/server/nginx
声明 LuaJIT 位置
# tell nginx's build system where to find LuaJIT 2.1: export LUAJIT_LIB=/usr/local/lib export LUAJIT_INC=/usr/local/include/luajit-2.1
Nginx编译参数
# Here we assume Nginx is to be installed under /opt/nginx/. ./configure --prefix=/opt/nginx \ --with-ld-opt="-Wl,-rpath,/usr/local/lib" \ --add-module=/path/to/lua-nginx-module
修改Nginx配置文件http{}
以启用
# add necessary `lua_package_path` directive to `nginx.conf`, in the http context lua_package_path "/www/server/nginx/lib/lua/?.lua;;";