使用lua可以为nginx扩展出强大的能力,比如频率限制,访问redis等,本文介绍一下如何安装模块lua-nginx-module
编译安装
下载
wget http://luajit.org/download/LuaJIT-2.0.5.tar.gz wget https://github.com/openresty/lua-nginx-module/archive/refs/tags/v0.10.20.tar.gz wget https://github.com/vision5/ngx_devel_kit/archive/refs/tags/v0.3.1.tar.gz
安装依赖
wget http://luajit.org/download/LuaJIT-2.0.5.tar.gz tar -zxvf LuaJIT-2.0.5.tar.gz cd LuaJIT-2.0.5 make install PREFIX=/usr/local/LuaJIT
设置lua环境变量: 添加到/etc/profile
export LUAJIT_LIB=/usr/local/LuaJIT/lib export LUAJIT_INC=/usr/local/LuaJIT/include/luajit-2.0
编译安装
./configure --add-module=../lua-nginx-module-0.10.20 --add-module=../ngx_devel_kit-0.3.1 make & make install
常见问题
[nginx: [alert] detected a LuaJIT version which is not OpenResty's; many optimizations will be disabled and performance will be compromised (see https://github.com/openresty/luajit2 for OpenResty's LuaJIT or, even better, consider using the OpenResty releases from https://openresty.org/en/download.html)]
./configure: error: unsupported LuaJIT version; ngx_http_lua_module requires LuaJIT 2.x. 需要先安装LuaJIT并配置环境变量
export LUAJIT_LIB=/usr/local/lib export LUAJIT_INC=/usr/local/include/luajit-2.0
本站部分文章搜集整理于互联网或者网友提供,如有侵权请联系站长
如若转载,请注明出处:https://htmlbk.com/note/2447.html
温馨提示:该文档最后一次修改时间为2024-03-19 09:49:28,请注意相关的内容是否还可用!