0x01 需求
waf本身有测试环境,但是在公司内网,我有的时候在家比较有空,所以需要一个测试环境在本机,同时也方便测试。之前在本地搭建过nginx,编译安装,没啥问题,自己本身对nginx还算了解,故障排查啥的都不是大问题,然后抱着这个想法就搞起来了。
0x02 过程
刚开始比较简单,就是下个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
0x03 坑来了
这会安装遇到一个问题,如下:
[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
0x04 结束
解决之后,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)