#LuaJIT
mkdir -p /root/lua_ngx && cd /root/lua_ngx
wget http://luajit.org/download/LuaJIT-2.0.5.tar.gz
tar zxvf LuaJIT-2.0.5.tar.gz
cd LuaJIT-2.0.5
make && make install
vim /etc/profile #注意路径
#export LUAJIT_LIB=/usr/local/lib
#export LUAJIT_INC=/usr/local/include/luajit-2.0
source /etc/profile

#ngx_devel_kit nginx_lua_module
cd /root/lua_ngx
#下载解压 https://codeload.github.com/simpl/ngx_devel_kit/tar.gz/v0.3.0
#下载解压 https://codeload.github.com/openresty/lua-nginx-module/tar.gz/v0.10.12rc1

[root@wow nginx-1.12.1]# nginx -V
nginx version: nginx/1.12.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)
built with OpenSSL 1.0.2l 25 May 2017
TLS SNI support enabled
configure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-ipv6 --with-http_sub_module --with-openssl=/root/lnmp1.4/src/openssl-1.0.2l --with-ld-opt=-ljemalloc --add-module=/root/nginx-rtmp-module-master

#编译,追加路径
service nginx stop
mv /usr/local/nginx /usr/local/nginx_bak
make clean
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-ipv6 --with-http_sub_module --with-openssl=/root/lnmp1.4/src/openssl-1.0.2l --with-ld-opt=-ljemalloc --add-module=/root/nginx-rtmp-module-master --add-module=/root/lua_ngx/ngx_devel_kit-0.3.0 --add-module=/root/lua_ngx/lua-nginx-module-0.10.12rc1
make
make install

[root@wow nginx]# nginx -V
nginx version: nginx/1.12.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)
built with OpenSSL 1.0.2l 25 May 2017
TLS SNI support enabled
configure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-ipv6 --with-http_sub_module --with-openssl=/root/lnmp1.4/src/openssl-1.0.2l --with-ld-opt=-ljemalloc --add-module=/root/nginx-rtmp-module-master --add-module=/root/lua_ngx/ngx_devel_kit-0.3.0 --add-module=/root/lua_ngx/lua-nginx-module-0.10.12rc1

4 对 “nginx开启lua支持”的想法;

  1. [root@test]# make
    make -f objs/Makefile
    make[1]: Entering directory `/usr/src/tengine-2.0.3'
    cc -c -I/usr/local/include/luajit-2.0 -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -DNDK_SET_VAR -I src/core -I src/event -I src/event/modules -I src/os/unix -I src/proc -I /root/lua_ngx/ngx_devel_kit-0.3.0/objs -I objs/addon/ndk -I /root/lua_ngx/lua-nginx-module-0.10.12rc1/src/api -I /usr/local/include/luajit-2.0 -I /usr/src/pcre-8.35 -I /root/openssl-1.0.2m/.openssl/include -I objs -I src/http -I src/http/modules -I /root/lua_ngx/ngx_devel_kit-0.3.0/src -I src/mail
    -o objs/addon/src/ngx_http_lua_script.o
    /root/lua_ngx/lua-nginx-module-0.10.12rc1/src/ngx_http_lua_script.c
    在包含自 /root/lua_ngx/lua-nginx-module-0.10.12rc1/src/ngx_http_lua_script.h:11 的文件中,
    从 /root/lua_ngx/lua-nginx-module-0.10.12rc1/src/ngx_http_lua_script.c:13:
    /root/lua_ngx/lua-nginx-module-0.10.12rc1/src/ngx_http_lua_common.h:39:2: 错误:#error at least nginx 1.6.0 is required but found an older version

    nginx版本过低

  2. Nginx提供了很多内置的变量,如:

    $arg_PARAMETER 这个变量包含在查询字符串时GET请求PARAMETER的值。
    $args 这个变量等于请求行中的参数。
    $binary_remote_addr 二进制码形式的客户端地址。
    $body_bytes_sent 传送页面的字节数
    $content_length 请求头中的Content-length字段。
    $content_type 请求头中的Content-Type字段。
    $cookie_COOKIE cookie COOKIE的值。
    $document_root 当前请求在root指令中指定的值。
    $document_uri 与$uri相同。
    $host 请求中的主机头字段,如果请求中的主机头不可用,则为服务器处理请求的服务器名称。
    $is_args 如果$args设置,值为”?”,否则为””。
    $limit_rate 这个变量可以限制连接速率。
    $nginx_version 当前运行的nginx版本号。
    $query_string 与$args相同。
    $remote_addr 客户端的IP地址。
    $remote_port 客户端的端口。
    $remote_user 已经经过Auth Basic Module验证的用户名。
    $request_filename 当前连接请求的文件路径,由root或alias指令与URI请求生成。
    $request_body 这个变量(0.7.58+)包含请求的主要信息。在使用proxy_pass或fastcgi_pass指令的location中比较有意义。
    $request_body_file 客户端请求主体信息的临时文件名。
    $request_completion 未知。
    $request_method 这个变量是客户端请求的动作,通常为GET或POST。包括0.8.20及之前的版本中,这个变量总为main request中的动作,如果当前请求是一个子请求,并不使用这个当前请求的动作。
    $request_uri 这个变量等于包含一些客户端请求参数的原始URI,它无法修改,请查看$uri更改或重写URI。
    $scheme 所用的协议,比如http或者是https,比如rewrite ^(.+)$ $scheme://example.com$1 redirect;
    $server_addr 服务器地址,在完成一次系统调用后可以确定这个值,如果要绕开系统调用,则必须在listen中指定地址并且使用bind参数。
    $server_name 服务器名称。
    $server_port 请求到达服务器的端口号。
    $server_protocol 请求使用的协议,通常是HTTP/1.0或HTTP/1.1。
    $uri 请求中的当前URI(不带请求参数,参数位于$args),可以不同于浏览器传递的$request_uri的值,它可以通过内部重定向,或者使用index指令进行修改。
    另外: HTTP_X_FORWARDED_FOR是透过代理服务器取得客户端的真实IP地址,有些用此方法读取到的仍然是代理服务器的IP。还有一点需要注意的是:如果客户端没有通过代理服务器来访问,那么用 HTTP_X_FORWARDED_FOR 取到的值将是空的。

    1. configure arguments: –user=www –group=www –prefix=/usr/local/nginx –with-http_stub_status_module –with-http_ssl_module –with-http_v2_module –with-http_gzip_static_module –with-ipv6 –with-http_sub_module –with-openssl=/root/lnmp1.4/src/openssl-1.0.2l –with-ld-opt=-ljemalloc –add-module=/root/nginx-rtmp-module-master –add-module=/root/lua_ngx/ngx_devel_kit-0.3.0 –add-module=/root/lua_ngx/lua-nginx-module-0.10.12rc1 –add-module=/root/lua_ngx/echo-nginx-module

回复 Nova 取消回复

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code