Nginx安装lua-nginx-module模块

如果是还没有安装nginx的小伙伴可以直接下载openresty安装简单快捷,http://openresty.org/cn/installation.html

安装了nginx的小伙伴就继续往下看咯~

1.下载安装LuaJIT 2.1(2.0或者2.1都是支持的,官方推荐2.1)
http://luajit.org/download.html

wget http://luajit.org/download/LuaJIT-2.1.0-beta2.tar.gz
tar zxf LuaJIT-2.1.0-beta2.tar.gz
cd LuaJIT-2.1.0-beta2
make PREFIX=/usr/local/luajit
make install PREFIX=/usr/local/luajit

2.下载最新的ngx_devel_kit(NDK)模块
https://github.com/simpl/ngx_devel_kit/tags

wget https://github.com/simpl/ngx_devel_kit/archive/v0.2.19.tar.gz
tar -xzvf v0.2.19.tar.gz

3.下载最新的lua-nginx-module 模块
https://github.com/openresty/lua-nginx-module/tags

wget https://github.com/openresty/lua-nginx-module/archive/v0.10.2.tar.gz
tar -xzvf v0.10.2.tar.gz

nginx -v看下nginx版本下载相同的版本源码,如果有了就进入源码目录不是安装目录哦

# tell nginx's build system where to find LuaJIT 2.1:
export LUAJIT_LIB=/usr/local/luajit/lib
export LUAJIT_INC=/usr/local/luajit/include/luajit-2.1

nginx -V看下之前的安装都带了哪些参数

./configure (之前安装的参数) --with-ld-opt="-Wl,-rpath,/usr/local/luajit/lib" --add-module=/path/to/ngx_devel_kit --add-module=/path/to/lua-nginx-module
--add-module后参数路径根据解压路径为准
make -j2
make install

4.验证lua-nginx-module安装是否成功
在nginx下配置

location /hello_lua { 
      default_type 'text/plain'; 
      content_by_lua 'ngx.say("hello, lua")'; 
}

访问显示hello, lua说明lua-nginx-module安装成功了~~~

发表评论

电子邮件地址不会被公开。 必填项已用*标注