nginx lua 學習記錄

2021-08-29 05:10:14 字數 2351 閱讀 3773

記錄一下環境搭建過程
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

firoot_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

??? nginx lua問題記錄

問題1 當用http localhost test 訪問時,結果為何迥異?eg1 location test 結果為空,說明執行的是httpechomodule的echo指令,沒有執行httpluamodule的content by lua指令 eg2 location test輸出123 說明執行...

nginx lua學習筆記

一.本地linux環境搭建 1.安裝vmware 2.安裝centos 3.centos關閉防火牆 當然只是方便學習用才關閉 etc init.d iptables stop 4.新增使用者 useradd test passwd test 5.配置ssh vim etc ssh sshd conf...

Nginx Lua學習筆記 環境搭建

使用的openresty 具體教程可以參考 這裡只記錄下我自己的環境搭建過程 系統使用的是ubuntu 14.04.1 server amd64.iso 所有操作都使用了sudo提權.首先參考解決apt get install時media change please insert the disc ...