nginx+lua 学习记录

nginx+lua 学习记录

记录一下环境搭建过程

下载一堆源码:

dl@dl:~/workspace/eotu_nginx$ ls -al
总用量 44
drwxrwxr-x 11 dl dl 4096 Oct  9 17:32 .
drwxrwxr-x 31 dl dl 4096 Oct 16 15:45 ..
drwxrwxr-x  4 dl dl 4096 Oct  9 15:54 debug
drwxrwxr-x  6 dl dl 4096 Oct  9 10:44 echo-nginx-module
drwxrwxr-x  8 dl dl 4096 Oct 17 17:06 .git
drwxr-xr-x  4 dl dl 4096 Jun 27 00:21 lua-5.3.5
drwxrwxr-x  7 dl dl 4096 Oct  9 10:05 luajit-2.0
drwxrwxr-x 11 dl dl 4096 Oct  9 10:13 lua-nginx-module
drwxr-xr-x  9 dl dl 4096 Oct  9 10:20 nginx-1.13.6
drwxrwxr-x 10 dl dl 4096 Oct  9 10:10 ngx_devel_kit
drwxrwxr-x  6 dl dl 4096 Oct  9 16:49 stream-lua-nginx-module

nginx-1.13.6中,创建了一个编译文件gcc.sh:

export LUAJIT_LIB=/usr/local/lib/
export LUAJIT_INC=/usr/local/include/luajit-2.0/
 ./configure --prefix=/home/dl/workspace/eotu_nginx/debug/nginx \
         --with-ld-opt="-Wl,-rpath,/path/to/luajit-or-lua/lib" \
         --add-module=/home/dl/workspace/eotu_nginx/ngx_devel_kit \
         --add-module=/home/dl/workspace/eotu_nginx/lua-nginx-module \
         --add-module=/home/dl/workspace/eotu_nginx/echo-nginx-module \
         --add-module=/home/dl/workspace/eotu_nginx/stream-lua-nginx-module \
         --with-cc-opt="-DNGX_LUA_USE_ASSERT -DNGX_LUA_ABORT_AT_PANIC" \
         --with-stream
echo "configure done!"
#make 
#echo "make done!"

编译后的结果在 ./debug文件夹中,创建了一个运行nginx简易脚本start_nginx.sh

#!/bin/bash

process=$(ps aux |grep sbin/nginx |grep -v grep)
if [ ! "$process" = "" ]; then
    echo "kill old nginx"
    killall -9 nginx
fi

root_path=$(pwd)
ngx_root=$root_path/nginx

ngx=$ngx_root/sbin/nginx
ngx_conf=$ngx_root/conf/nginx.conf

res=$($ngx -c $ngx_conf -t 2>&1)

if [[ "$res" = *successful* ]]; then
    #echo "TEST CONFIG successful"
    case $1 in
        -f)
            echo "start nginx in foreground"
            $ngx -c $ngx_conf -g 'daemon off;'
        ;;
        *)
            echo "start nginx in backgrouad"
            $ngx -c $ngx_conf
        ;;
    esac
else
    echo "TEST CONFIG FAIL"
    echo $res
fi

nginx + lua 编程可以在./debug/nginx文件夹中,配置nginx.conf文件,lua编程文件夹在./debug/nginx/lua

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值