WAF 로 컬 테스트 환경 구축 (tengine + lua)

6307 단어
수요
waf 자체 에 테스트 환경 이 있 지만 회사 내 네트워크 에서 저 는 가끔 집에 서 시간 이 있 기 때문에 테스트 환경 이 이 기계 에 있어 야 하고 테스트 도 편리 합 니 다.이전에 현지에서 nginx 를 구축 한 적 이 있 습 니 다. 컴 파일 하고 설치 한 적 이 있 습 니 다. 문제 가 없습니다. 자신 은 nginx 에 대해 잘 알 고 있 습 니 다. 고장 검사 같은 것 은 큰 문제 가 아니 라 는 생각 을 가지 고 이 생각 을 하 게 되 었 습 니 다.
0x 02 과정
처음에는 간단 했다. 바로 다음 lua 였 다. 그리고 설치 했다. 과정 은 말 하지 않 고 바로 해 냈 다.
[root@localhost ~]# wget http://luajit.org/download/LuaJIT-2.0.4.tar.gz
--2017-02-15 17:30:30--  http://luajit.org/download/LuaJIT-2.0.4.tar.gz
Resolving luajit.org... 163.172.177.144
Connecting to luajit.org|163.172.177.144|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 847615 (828K) [application/octet-stream]
Saving to: `LuaJIT-2.0.4.tar.gz'

100%[======================================>] 847,615      309K/s   in 2.7s    

2017-02-15 17:30:33 (309 KB/s) - `LuaJIT-2.0.4.tar.gz' saved [847615/847615]

설치:
[root@localhost ~]# tar xvf LuaJIT-2.0.4.tar.gz 
[root@localhost ~]# cd LuaJIT-2.0.4
[root@localhost LuaJIT-2.0.4]# ls
COPYRIGHT  doc  dynasm  etc  Makefile  README  src
[root@localhost LuaJIT-2.0.4]# make
==== Building LuaJIT 2.0.4 ====
make -C src
make[1]: Entering directory `/root/LuaJIT-2.0.4/src'
HOSTCC    host/minilua.o
......
OK        Successfully built LuaJIT
make[1]: Leaving directory `/root/LuaJIT-2.0.4/src'
==== Successfully built LuaJIT 2.0.4 ====
[root@localhost LuaJIT-2.0.4]# make install
==== Installing LuaJIT 2.0.4 to /usr/local ====
mkdir -p /usr/local/bin /usr/local/lib /usr/local/include/luajit-2.0 /usr/local/share/man/man1 /usr/local/lib/pkgconfig /usr/local/share/luajit-2.0.4/jit /usr/local/share/lua/5.1 /usr/local/lib/lua/5.1
cd src && install -m 0755 luajit /usr/local/bin/luajit-2.0.4
cd etc && sed -e "s|^prefix=.*|prefix=/usr/local|" -e "s|^multilib=.*|multilib=lib|" luajit.pc > luajit.pc.tmp && \
      install -m 0644 luajit.pc.tmp /usr/local/lib/pkgconfig/luajit.pc && \
      rm -f luajit.pc.tmp
cd src && install -m 0644 lua.h lualib.h lauxlib.h luaconf.h lua.hpp luajit.h /usr/local/include/luajit-2.0
cd src/jit && install -m 0644 bc.lua v.lua dump.lua dis_x86.lua dis_x64.lua dis_arm.lua dis_ppc.lua dis_mips.lua dis_mipsel.lua bcsave.lua vmdef.lua /usr/local/share/luajit-2.0.4/jit
ln -sf luajit-2.0.4 /usr/local/bin/luajit
==== Successfully installed LuaJIT 2.0.4 to /usr/local ====

그리고 끝 났 습 니 다. lua 설 치 는 가장 간단 합 니 다. 할 말 이 없습니다.그 다음 에 tengine 의 설치 입 니 다. 이 과정 은 비교적 기구 합 니 다. 명령 만 기록 하고 구체 적 으로 print 하지 않 습 니 다.
tar xvf tengine-2.2.0.tar.gz 
cd tengine-2.2.0

./configure --with-http_lua_module --with-luajit-lib=/usr/local/lib/ --with-luajit-inc=/usr/local/include/luajit-2.0/ --with-lua-inc=/usr/local/include/luajit-2.0/ --with-lua-lib=/usr/local/lib/

make || make install

0x 03 구덩이 가 왔 다
이것 은 설치 에 문제 가 생 길 수 있 습 니 다. 다음 과 같 습 니 다.
[root@localhost sbin]# ./nginx -m 
./nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such file or directory

마지막 에 해결 됐어 요.
echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
ldconfig 

0x 04 종료
해결 후 nginx - m 는 로 딩 모듈 을 보고 나무 에 lua 가 있 는 모듈 에 대응 하면 끝 납 니 다.

nginx: loaded modules:
nginx:     ngx_core_module (static)
nginx:     ngx_errlog_module (static)
nginx:     ngx_conf_module (static)
nginx:     ngx_dso_module (static)
nginx:     ngx_events_module (static)
nginx:     ngx_event_core_module (static)
nginx:     ngx_epoll_module (static)
nginx:     ngx_procs_module (static)
nginx:     ngx_proc_core_module (static)
nginx:     ngx_openssl_module (static)
nginx:     ngx_regex_module (static)
nginx:     ngx_http_module (static)
nginx:     ngx_http_core_module (static)
nginx:     ngx_http_log_module (static)
nginx:     ngx_http_upstream_module (static)
nginx:     ngx_http_static_module (static)
nginx:     ngx_http_autoindex_module (static)
nginx:     ngx_http_index_module (static)
nginx:     ngx_http_auth_request_module (static)
nginx:     ngx_http_auth_basic_module (static)
nginx:     ngx_http_access_module (static)
nginx:     ngx_http_limit_conn_module (static)
nginx:     ngx_http_limit_req_module (static)
nginx:     ngx_http_geo_module (static)
nginx:     ngx_http_map_module (static)
nginx:     ngx_http_split_clients_module (static)
nginx:     ngx_http_referer_module (static)
nginx:     ngx_http_rewrite_module (static)
nginx:     ngx_http_ssl_module (static)
nginx:     ngx_http_proxy_module (static)
nginx:     ngx_http_fastcgi_module (static)
nginx:     ngx_http_uwsgi_module (static)
nginx:     ngx_http_scgi_module (static)
nginx:     ngx_http_memcached_module (static)
nginx:     ngx_http_empty_gif_module (static)
nginx:     ngx_http_browser_module (static)
nginx:     ngx_http_user_agent_module (static)
nginx:     ngx_http_upstream_hash_module (static)
nginx:     ngx_http_upstream_ip_hash_module (static)
nginx:     ngx_http_upstream_consistent_hash_module (static)
nginx:     ngx_http_upstream_check_module (static)
nginx:     ngx_http_upstream_least_conn_module (static)
nginx:     ngx_http_upstream_keepalive_module (static)
nginx:     ngx_http_upstream_dynamic_module (static)
nginx:     ngx_http_stub_status_module (static)
nginx:     ngx_http_write_filter_module (static)
nginx:     ngx_http_header_filter_module (static)
nginx:     ngx_http_chunked_filter_module (static)
nginx:     ngx_http_range_header_filter_module (static)
nginx:     ngx_http_gzip_filter_module (static)
nginx:     ngx_http_postpone_filter_module (static)
nginx:     ngx_http_ssi_filter_module (static)
nginx:     ngx_http_charset_filter_module (static)
nginx:     ngx_http_userid_filter_module (static)
nginx:     ngx_http_footer_filter_module (static)
nginx:     ngx_http_trim_filter_module (static)
nginx:     ngx_http_headers_filter_module (static)
nginx:     ngx_http_upstream_session_sticky_module (static)
nginx:     ngx_http_reqstat_module (static)
nginx:     ngx_http_lua_module (static)   ------------------     !!!!
nginx:     ngx_http_copy_filter_module (static)
nginx:     ngx_http_range_body_filter_module (static)
nginx:     ngx_http_not_modified_filter_module (static)

좋은 웹페이지 즐겨찾기