美文网首页
Nginx安装lua-nginx-module

Nginx安装lua-nginx-module

作者: 十毛tenmao | 来源:发表于2021-07-05 23:56 被阅读0次

    使用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
    
    • nginx: [alert] failed to load the 'resty.core' module

    参考

    参考

    • 已安装的nginx如何添加模块

      • 下载模块:
      • --add-module=/Users/timxia/Downloads/nginx-dep/lua-nginx-module-0.10.20
      • brew install luajit
      • export LUAJIT_INC=/usr/local/Cellar/luajit/2.0.5/include/luajit-2.0
      • export LUAJIT_LIB=/usr/local/Cellar/luajit/2.0.5/lib

    相关文章

      网友评论

          本文标题:Nginx安装lua-nginx-module

          本文链接:https://www.haomeiwen.com/subject/jrewultx.html