编译安装nginx支持lua

1、下载lua模块
    wget https://github.com/openresty/lua-nginx-module/archive/v0.10.9rc7.tar.gz
    解压到/usr/local/目录下
    tar xvf v0.10.9rc7.tar.gz -C /usr/local
  2、下载nginx拓展模块
    wget https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz
    是一个拓展nginx服务器核心功能的模块,第三方模块开发可以基于它来快速实现
    解压到/usr/local/目录下
    tar xvf v0.3.0.tar.gz -C /usr/local
  3、准备lua环境
    wget http://luajit.org/download/LuaJIT-2.0.4.tar.gz
    tar xvf LuaJIT-2.0.4.tar.gz
    cd LuaJIT-2.0.4
    make install PREFIX=/usr/local/luajit
    配置环境变量:
    vim /etc/profile.d/lua.sh
      export LUAJIT_LIB=/usr/local/luajit/lib
      export LUAJIT_INC=/usr/local/luajit/include/luajit-2.0
    加载环境变量:source /etc/profile.d/lua.sh




1、下载nginx源码包
    wget http://nginx.org/download/nginx-1.16.1.tar.gz
  2、解压后编译安装
    tar xvf nginx-1.16.1.tar.gz
    cd nginx-1.16.1
    ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_sub_module --with-http_ssl_module --add-module=/usr/local/ngx_devel_kit-0.3.0 --add-module=/usr/local/lua-nginx-module-0.10.9rc7
    make
    make install







注意:如果遇上如下报错:
  nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such file or directory
    解决方案简单粗暴:yum install lua* -y
  创建软连接方便执行nginx相关命令
  ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx

 

posted @ 2022-11-24 16:52  力王7314  阅读(133)  评论(0编辑  收藏  举报