安装LuaJIT:
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模块:
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
测试:
location /lua {
default_type 'text/plain';
content_by_lua "ngx.print(ngx.var['arg_tag'], '\\n')";
}
访问:
curl -i '192.168.1.2/lua?tag=hello'
标签:none