在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
lua-nginx-module模块地址 https://github.com/openresty/lua-nginx-module It is highly recommended to use OpenResty releases which integrate Nginx, ngx_lua, LuaJIT 2.1, as well as other powerful companion Nginx modules and Lua libraries. It is discouraged to build this module with nginx yourself since it is tricky to set up exactly right. Also, the stock nginx cores have various limitations and long standing bugs that can make some of this modules' features become disabled, not work properly, or run slower. The same applies to LuaJIT as well. OpenResty includes its own version of LuaJIT which gets specifically optimized and enhanced for the OpenResty environment. 如果不听人家的建议,可以按照下面安装 Alternatively, ngx_lua can be manually compiled into Nginx:
Build the source with this module: wget 'http://nginx.org/download/nginx-1.13.6.tar.gz'
tar -xzvf nginx-1.13.6.tar.gz
cd nginx-1.13.6/
# tell nginx's build system where to find LuaJIT 2.0:
export LUAJIT_LIB=/path/to/luajit/lib
export LUAJIT_INC=/path/to/luajit/include/luajit-2.0
# tell nginx's build system where to find LuaJIT 2.1:
export LUAJIT_LIB=/path/to/luajit/lib
export LUAJIT_INC=/path/to/luajit/include/luajit-2.1
# or tell where to find Lua if using Lua instead:
#export LUA_LIB=/path/to/lua/lib
#export LUA_INC=/path/to/lua/include
# Here we assume Nginx is to be installed under /opt/nginx/.
./configure --prefix=/opt/nginx \
--with-ld-opt="-Wl,-rpath,/path/to/luajit-or-lua/lib" \
--add-module=/path/to/ngx_devel_kit \
--add-module=/path/to/lua-nginx-module
# Note that you may also want to add `./configure` options which are used in your
# current nginx build.
# You can get usually those options using command nginx -V
# you can change the parallism number 2 below to fit the number of spare CPU cores in your
# machine.
make -j2
make install
ngx_lua_module 是一个nginx http模块,它把 lua 解析器内嵌到 nginx,用来解析并执行lua 语言编写的网页后台脚本 特性很牛叉,可自行百度查看,这里主要是示范一下,如何在Nginx下安装lua-nginx-module模块 当然,如果你之前没有安装过Nginx,而且嫌安装麻烦,可直接下载openresty安装简单快捷,http://openresty.org/cn/installation.html(阿里的大牛章亦春的作品,膜拜~~~) 1.下载安装LuaJIT 2.1(2.0或者2.1都是支持的,官方推荐2.1):http://luajit.org/download.html
2.下载ngx_devel_kit(NDK)模块 :https://github.com/simpl/ngx_devel_kit/tags,不需要安装
3.下载最新的lua-nginx-module 模块 :https://github.com/openresty/lua-nginx-module/tags,不需要安装
4.nginx -V查看已经编译的配置
笔者的配置如下:
5.进入之前安装nginx的解压目录,重新编译安装(在nginx -V得到的配置下,加入ngx_devel_kit-0.2.19和ua-nginx-module-0.10.2的目录),最终的配置如下: 设置环境变量
6.编译安装
7.查看是否编译成功 在/usr/local/nginx/conf/nginx.conf中加入如下代码:
重启nginx:
访问10.211.55.3/hello_lua会出现”hello, lua”表示安装成功
|
请发表评论