Nginx安装lua支持

需要LuaJIT-2.0.4.tar.gz,ngx_devel_kit,lua-nginx-module

1.下载安装LuaJIT-2.0.4.tar.gz

wget -c http://luajit.org/download/LuaJIT-2.0.4.tar.gz

tar xzvf LuaJIT-2.0.4.tar.gz

cd LuaJIT-2.0.4

make install PREFIX=/usr/local/luajit

#注意环境变量!

export LUAJIT_LIB=/usr/local/luajit/lib

export LUAJIT_INC=/usr/local/luajit/include/luajit-2.0

2.下载解压ngx_devel_kit

git clone https://github.com/simpl/ngx_devel_kit

3.下载解压lua-nginx-module

git clone https://github.com/openresty/lua-nginx-module

4、lnmp升级[https://github.com/licess/lnmp]

vim ~/lnmp1.6/lnmp.conf

Nginx_Modules_Options='--add-module=/tmp/ngx_devel_kit --add-module=/tmp/lua-nginx-module'

./upgrade.sh nginx

5.验证

#将nginx做成命令

ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx

cd /usr/local/nginx/conf/

vi nginx.conf

#lua指令方式

#在server 中添加一个localtion

location /hello {

            default_type ‘text/plain’;

            content_by_lua ‘ngx.say(“hello, lua”)’;

        }

Leave Comment

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