nginx+lua 开发记录

/ default / 0 条评论 / 2066浏览

1、nginx+lua 官网

https://www.nginx.com/resources/wiki/modules/lua/ 一行小字 This document has been moved to openresty/lua-nginx-module#readme

转至 github

2、Installation

Install LuaJIT 2.0 or 2.1 (recommended) or Lua 5.1 (Lua 5.2 is not supported yet). LuaJIT can be downloaded from the LuaJIT project website and Lua 5.1, from the Lua project website. Some distribution package managers also distribute LuaJIT and/or Lua. Download the latest version of the ngx_devel_kit (NDK) module HERE. Download the latest version of ngx_lua HERE. Download the latest version of Nginx HERE (See Nginx Compatibility)

个人推荐luaJit 效率略胜Lua LuaJit 2.0是稳定版本 个人倾向稳定性。选的2.05 没选2.1

选择并下载完成后

cd /usr/local
sudo mkdir nginx-lua-modeule
cd nginx-lua-modeule
通过cp指令将下载的3个内容 复制过来 到/usr/local/nginx-lua-module
通过tar -zxvf 将3个文件解压缩 

如图 请输入图片描述

cd LuaJIT-2.0.5/
make install PREFIX=/usr/local/luaJit

切换到Nginx的源码解压文件夹下 执行

 export LUAJIT_LIB=/path/to/luaJit/lib
 export LUAJIT_INC=/path/to/luaJit/include/luajit-2.0

依旧在Nginx的源码解压文件夹下

 sudo ./configure --prefix=/usr/local/nginx          --with-ld-opt="-Wl,-rpath,/usr/local/luaJit/lib"          --add-module=/usr/local/nginx-lua-module/ngx_devel_kit-0.3.1rc1          --add-module=/usr/local/nginx-lua-module/lua-nginx-module-0.10.13
 sudo make -j2
 sudo make install

-j2 的2 指的是2核来处理 根据服务器自身条件调整。