nginx1.7 添加lua

 nginx1.7 添加lua


1:下载ngx_devel_kit.tar.gz 解压


2:下载nginx_lua_module.tar.gz 解压




3:# cd 到nginx的安装模块  后面跟的--add-module  即ngx_devel_kit和nginx_lua_module 解压路径  
//注: 这里的openssh 和 pcre 也要下载解压(安装ngxin已经说了)
./configure --prefix=/usr/local/nginx --pid-path=/var/run/nginx.pid  --with-openssl=/home/guotonglin/nginx/openssh-6.0p1 --with-pcre=/home/guotonglin/nginx/pcre-8.35 --with-http_stub_status_module --add-module=/home/guotonglin/nginx/lua-nginx-module-0.9.12rc2 --add-module=/home/guotonglin/nginx/ngx_devel_kit-0.2.19


4:执行make 和make install 命令


5:我这里是要实现监听反向代理服务器的返回内容:


具体的nginx.conf 配置:


//添加到http 和server之间
    log_format  main  '$resp_body - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent"  "$http_x_forwarded_for"';  // 这里是日志要显示的格式,我自己添加了 $resp_body(因为我要拿服务器返回的数据)
    
    
    //  server 和location 之间
    
     lua_need_request_body on;
        set $resp_body "";
        body_filter_by_lua '
            local resp_body = string.sub(ngx.arg[1], 1, 1000)
            ngx.ctx.buffered = (ngx.ctx.buffered or "") .. resp_body
            if ngx.arg[2] then
                ngx.var.resp_body = ngx.ctx.buffered
            end
        ';
        
        
        
启动nginx会报 如下错误 (复制来的)
./sbin/nginx: error while loading shared libraries:libluajit-5.1.so.2: cannot open shared object file: No such file or directory
此类问题通常使用ldconfig命令就能解决:
echo "/usr/local/lib" >/etc/ld.so.conf.d/usr_local_lib.conf
ldconfig
重启nginx        
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值