当前位置: > Linux服务器 > nginx >

Nginx添加Lua支持

时间:2016-12-18 10:08来源:linux.it.net.cn 作者:IT
 
2
3
4
5
6
wget http://luajit.org/download/LuaJIT-2.0.2.tar.gz
tar zxvf LuaJIT-2.0.2.tar.gz
make && make install PREFIX=/usr/local/luajit2.02
echo "/usr/local/luajit2.02/lib" > /etc/ld.so.conf.d/luajit.conf
export LUAJIT_LIB=/usr/local/luajit2.02/lib/
export LUAJIT_INC=/usr/local/luajit2.02/include/

安装Nginx及Ngx_lua模块:

1
2
3
4
5
6
7
8
9
10
wget http://nginx.org/download/nginx-1.4.4.tar.gz
tar zxvf nginx-1.4.4.tar.gz
cd nginx-1.4.4/
wget -O ngx_devel_kit0.2.19.tar.gz https://github.com/simpl/ngx_devel_kit/archive/v0.2.19.tar.gz
tar zxvf ngx_devel_kit0.2.19.tar.gz
wget -O lua-nginx0.9.3.tar.gz https://github.com/chaoslawful/lua-nginx-module/archive/v0.9.3.tar.gz
tar zxvf lua-nginx0.9.3.tar.gz
./configure --prefix=/usr/local/nginx1.4.4 --conf-path=/etc/nginx/nginx.conf --with-ipv6 \
--with-http_ssl_module --add-module=./ngx_devel_kit-0.2.19/ --add-module=./lua-nginx-module-0.9.3/
make && make install

测试:

1
2
3
4
location /lua {
    default_type 'text/plain';
    content_by_lua "ngx.print(ngx.var['arg_tag'], '\\n')";
}

访问:

1
curl -i '192.168.1.2/lua?tag=hello'



(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容