准备文件:
国人开发的,超级厉害,这是编译nginx源码,另外一种就是使用openresty大神已经帮忙集成了很多优秀的第三方模块。
1、nginx源码文件:http://nginx.org/download/nginx-1.11.10.tar.gz
2、LuaJIT:http://luajit.org/download/LuaJIT-2.0.4.tar.gz
3、pcre:ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz
4、ngx_devel_kit:https://github.com/simpl/ngx_devel_kit/archive/master.zip
5、nginx_lua_module:https://github.com/openresty/lua-nginx-module/archive/v0.10.7.tar.gz
6、ngx_echo模块:https://github.com/openresty/stream-echo-nginx-module/archive/master.zip
安装
1、LuaJit安装:
# tar xf LuaJIT-2.0.4.tar.gz
# cd LuaJIT-2.0.4
# make && make install
# 直接使用源码安装,lib和include放在/usr/local/lib与/usr/local/include下
# 修改环境变量:LUAJIT_LIB,LUAJIT_INC
# /etc/profile.d/luajit.sh
# export LUAJIT_LIB=/usr/local/lib
# export LUAJIT_INC=/usr/local/include/luajia-2.0
2、编译nginx
# ./configure --prefix=/usr/local/nginx1 --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-pcre=../pcre-8.39 --add-module=../ngx_devel_kit-master/ --add-module=../lua-nginx-module-0.10.7/ --add-module=../echo-nginx-module-0.60/
# make && make install
# nginx编译添加第三方扩展模块:--add-module=模块路径
3、测试,(不能将echo与ngx.say放到一个location测试)
# server {
# location /hello {
# default_type 'text/html';
# content_by_lua 'ngx.say("hello,lua")';
# }
# location /test_echo {
# echo "request-method: $request-method";
# }
# }
#
# curl 'http://localhost/hello'
# curl 'http://localhost/test_echo'
openresty安装
http://openresty.org/cn/installation.html
Nginx学习文档:
http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html#00-Foreword0#
tengine.taobao.org/book/index.html#id2
网友评论