nginx获取post body值(搭建nginx + lua)

nginx 配置 lua

https://github.com/openresty/lua-nginx-module#installation

1. 下载安装LuaJIT

wget http://luajit.org/download/LuaJIT-2.0.5.tar.gz
tar -xvzf
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

wget https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz
tar -xvzf

3. 下载解压lua-nginx-module

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

4. 下载安装nginx

wget http://nginx.org/download/nginx-1.14.0.tar.gz

tar -xvzf 

./configure --add-module=/home/caozhen/ngx_devel_kit-0.3.0 --add-module=/home/caozhen/lua-nginx-module-0.10.13

make && make install 

5. 配置

vi nginx.conf;

lua指令方式

#在server 中添加一个localtion

location /hello {

            default_type 'text/plain';

            content_by_lua 'ngx.say("hello, lua")';

        }

#lua文件方式

#在server 中添加一个localtion

location /lua {

    default_type 'text/html';

    content_by_lua_file conf/lua/test.lua; #相对于nginx安装目录

}

#test.lua文件内容

ngx.say("hello world");

6. 启动:

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/logServer.conf

报错nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such file or directory
可以执行 :ln -s /usr/local/luajit/lib/libluajit-5.1.so.2 /usr/lib64/libluajit-5.1.so.2

7. 测试:

curl -i -d "arg1=1&arg2=2" "http://127.0.0.1:6699/post/"

你可能感兴趣的:(文档,nginx,post,lua)