• CentOS7.6下安装nginx1.20.1及nginx动态模块使用


    需求说明

    1. 在系统中安装nginx1.20.1
    2. 动态引入stream模块

    配置步骤

    下载编译源码包

    1. 下载源码包到指定的目录,本次目录是在/u01下
    wget http://nginx.org/download/nginx-1.20.1.tar.gz
    
    1. 解压并编译源码

    本次编译的时候指定使用http_stub_status_module和http_ssl_module

    tar -zxvf  nginx-1.20.1.tar.gz
    cd nginx-1.20.1/
    

    配置编译使用的模块

    ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
    

    编译

    make
    
    make install
    
    1. 进入目录,测试访问
    cd /usr/local/nginx/sbin/
    ./nginx
    curl localhost
    

    编译stream模块

    1. 进入之前下载解压后的源码包内
    cd /u01/nginx-1.20.1/
    
    1. 查看nginx支持的动态模块
    [root@load-eco nginx-1.20.1]# ./configure --help | grep dynamic
      --with-http_xslt_module=dynamic    enable dynamic ngx_http_xslt_module
      --with-http_image_filter_module=dynamic
                                         enable dynamic ngx_http_image_filter_module
      --with-http_geoip_module=dynamic   enable dynamic ngx_http_geoip_module
      --with-http_perl_module=dynamic    enable dynamic ngx_http_perl_module
      --with-mail=dynamic                enable dynamic POP3/IMAP4/SMTP proxy module
      --with-stream=dynamic              enable dynamic TCP/UDP proxy module
      --with-stream_geoip_module=dynamic enable dynamic ngx_stream_geoip_module
      --add-dynamic-module=PATH          enable dynamic external module
      --with-compat                      dynamic modules compatibility
    
    
    1. 编译指定模块
    ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-stream=dynamic
    

    注意,此时只需要make即可,不要执行make install

    make
    
    1. 复制编译后的模块文件

    在编译后,在/u01/nginx-1.20.1/objs中会有编译好的 ngx_stream_module.so模块,此时只需要将模块复制到nginx的工作目录即可,如果在nginx目录中没有modules也可以自己建立一个

    cp ngx_stream_module.so    nginx_worker_dir/modules/
    
    1. 修改nginx.conf配置文件,载入模块
    load_module  modules/ngx_stream_module.so;
    
    stream {
       ....
    }
    
    
    1. 新加载配置

    官方介绍

    https://nginx.org/en/docs/configure.html
    https://nginx.org/en/docs/stream/ngx_stream_core_module.html

  • 相关阅读:
    考研岁月
    sklearn 翻译笔记:KNeighborsClassifier
    网站不让复制的办法
    关于VMware Workstation 15 Player 虚拟机安装Windows系统却无法安装vmware tools的解决
    今天真是太傻了
    GoogleHacking相关技巧
    判断ARP欺骗
    Linux各个文件及其含义
    小白的开始—转一篇Linux系统入门的文章
    课时39.细线表格(理解)
  • 原文地址:https://www.cnblogs.com/GYoungBean/p/15128007.html
Copyright © 2020-2023  润新知