`

lua-nginx-module和echo-nginx-module试用

    博客分类:
  • lua
 
阅读更多

参考资料

https://github.com/chaoslawful/lua-nginx-module

 

https://github.com/agentzh/echo-nginx-module

 

将nginx,lua-nginx-module,echo-nginx-module从git上下载下来。

我的都下载到了

/home/fansxnet/gitproject/目录下了。

 

cd /home/fansxnet/gitproject/nginx

 

 

 

 ./configure --user=fansxnet --group=fansxnet  --prefix=/home/fansxnet/gitproject/nginx --add-module=/home/fansxnet/gitproject/echo-nginx-module --add-module=/home/fansxnet/gitproject/lua-nginx-module

 

 

 

adding module in /home/fansxnet/gitproject/echo-nginx-module
 + ngx_http_echo_module was configured
adding module in /home/fansxnet/gitproject/lua-nginx-module
checking for Lua library ... found
checking for export symbols by default ... found
 + ngx_http_lua_module was configured
checking for PCRE library ... found
checking for PCRE JIT support ... found
checking for system md library ... not found
checking for system md5 library ... not found
checking for OpenSSL md5 crypto library ... found
checking for sha1 in system md library ... not found
checking for OpenSSL sha1 crypto library ... found
checking for zlib library ... found
creating objs/Makefile

Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + md5: using system crypto library
  + sha1: using system crypto library
  + using system zlib library

  nginx path prefix: "/home/fansxnet/gitproject/nginx"
  nginx binary file: "/home/fansxnet/gitproject/nginx/sbin/nginx"
  nginx configuration prefix: "/home/fansxnet/gitproject/nginx/conf"
  nginx configuration file: "/home/fansxnet/gitproject/nginx/conf/nginx.conf"
  nginx pid file: "/home/fansxnet/gitproject/nginx/logs/nginx.pid"
  nginx error log file: "/home/fansxnet/gitproject/nginx/logs/error.log"
  nginx http access log file: "/home/fansxnet/gitproject/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp" 

 

 

编译的时候,提示库没有找到的,可以根据提示的库名,google后,一个个安装

 

 

make
# 如果没有错误,这一步就编译成功了。
 cd objs/
ls
addon  autoconf.err  Makefile  nginx  nginx.8  ngx_auto_config.h  ngx_auto_headers.h  ngx_modules.c  ngx_modules.o  src
#看到nginx,编译成功了。

 

 

 

修改配置文件 /home/fansxnet/gitproject/nginx/conf/nginx.conf

 

# 用户名,组
user fansxnet fansxnet;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;
        #access_log  logs/host.access.log  main;
	  #设置虚拟目录
        root /home/fansxnet/gitproject/nginx/html/;
        location / {
            root   html;
            index  index.html index.htm;
            }
	  #测试用的地址,多个文件合并成一个返回给浏览器
	  #http://127.0.0.1/merge?/js/jquery-1.2.6.min.js&/js/index.js
        location /merge {
          default_type 'text/javascript';
          echo_foreach_split '&' $query_string;
              echo "/* JS File $echo_it */";
              echo_location_async $echo_it;
              echo;
          echo_end;
            }
	  #测试用的地址,测试lua脚本执行 http://127.0.0.1/recur?num=5
        location /recur {
            # MIME type determined by default_type:
            default_type 'text/plain';

            content_by_lua '
               local num = tonumber(ngx.var.arg_num) or 0

               if num > 50 then
                   ngx.say("num too big")
                   return
               end

               ngx.say("num is: ", num)

               if num > 0 then
                   res = ngx.location.capture("/recur?num=" .. tostring(num - 1))
                   ngx.print("status=", res.status, " ")
                   ngx.print("body=", res.body)
               else
                   ngx.say("end")
               end
               ';
        }
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_name  localhost;

    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_timeout  5m;

    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers   on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

 

 

 

 

切换到root下。

注意我的当前路径是能够nginx源码目录 /home/fansxnet/gitproject/nginx/objs

 

 

./nginx
#启动后可以测试了
./nginx -s stop
# 停止了

 

分享到:
评论

相关推荐

    lua-nginx-module-0.10.13

    Lua-Nginx-Module,简称lua-nginx-module,是Nginx服务器的一个重要扩展模块,它将强大的Lua脚本语言集成到Nginx中,允许用户在Nginx配置文件中直接编写Lua代码,极大地增强了Nginx的功能性和灵活性。版本0.10.13是...

    echo-nginx-module-0.58.tar.gz

    而为了更好地优化和调试Nginx的配置,开发者们开发了一系列的模块,其中echo-nginx-module是其中之一。本文将详细解析echo-nginx-module的功能、使用场景以及如何配合Nginx进行调试。 一、echo-nginx-module概述 ...

    Openresty_For_Windows_1.7.10.zip

    echo-nginx-module form-input-nginx-module encrypted-session-nginx-module set-misc-nginx-module ngx-postgres-module ngx-lua-module ngx_lua_upstream headers-more-nginx-module rds-json-nginx-module nginx...

    nginx-echo-lua-module模块安装以及实验

    首先,你需要下载 Nginx 的源码和 Nginx Echo Lua 模块的源码。你可以通过 Git 从 GitHub 上克隆项目: ``` git clone https://github.com/openresty/nginx-echo-lua-module.git ``` 2. **构建 Nginx** 确保你...

    nginx-lua环境配置

    ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --add-module=../lua-nginx-module-0.9.15 --add-module=../ngx_devel_kit-0.2.19 make -j4 make install echo '/usr/local/lib' >> /etc/...

    nginx,lua模块安装

    这里添加了lua-nginx-module、echo-nginx-module和ngx_devel_kit三个第三方模块,它们是Nginx支持Lua脚本的关键。 3. **LuaJIT的安装** LuaJIT是一个高效的Lua虚拟机,通常用于提高Lua脚本的执行速度。从官方站点...

    nginx 整合redis以及lua语言

    5. `echo-nginx-module-0.52.tar.gz`: 提供了Nginx中的高级输出控制功能,如延迟发送、拼接字符串等,有助于调试和性能优化。 6. `ngx_devel_kit-0.2.19.tar.gz`: Nginx开发工具包,为创建新的Nginx模块提供了便利...

    NGINX + LUA实现复杂的控制

    mv chaoslawful-lua-nginx-module-ccaf132 lua_nginx_module tar zxvf v0.2.17rc2 mv simpl-ngx_devel_kit-bc97eea ngx_devel_kit tar zxvf pcre-8.12.tar.gz tar zxvf nginx-1.0.3.tar.gz cd nginx-1.0.3 ./...

    把Lua编译进nginx步骤方法

    --add-module=/data/src/lua-nginx-module-0.9.8 \ --add-module=/data/src/ngx_devel_kit-0.2.19 ``` 运行`make`和`make install`完成编译和安装。 6. 解决启动时可能出现的问题: 如果在启动Nginx时遇到“找...

    nginx-openresty-windows:nginx用于带有openresty的窗口

    更新echo-nginx-module到0.61 更新ngx_postgres到1.0 更新ngx_lua_upstream到0.07 更新ngx-lua-module到0.10.10 更新LuaJIT到2.1-20170808 库: 更新lua-resty-core到0.1.12 更新lua-resty-dns到0.19 更新lua-resty-...

    nginx 1.17.3.1 Unicorn.zip

    包含模块nginx, nginx doc, Lua, Naxsi, Rtmp, HttpSubsModule,echo-nginx, lower_upper_case, headers-more,auth_ldap, set-misc, lua-upstream, encrypted-session,limit-traffic, AJP, form-input, upstream_...

    Nginx如何封禁IP和IP段的实现

    Nginx作为一款广泛应用的高性能反向代理服务器和负载均衡器,其功能丰富多样,包括但不限于限流、缓存、黑白名单控制以及灰度发布等。在网络安全管理中,有时我们需要对特定的IP地址或IP段进行访问限制,以防止恶意...

    PHP服务器部署x_部署到服务器

    OpenResty是一个基于Nginx的高性能Web平台,集成了Lua脚本语言。在这里,我们将安装版本1.13.6.2: ```bash ./configure --with-http_ssl_module --with-http_v2_module --with-stream --with-...

Global site tag (gtag.js) - Google Analytics