zoukankan      html  css  js  c++  java
  • nginx编译新模块

    nginx编译新模块

    1.查看当前nginx编译模块

    [root@iZ2zehdwq9kcuuz64a2m22Z ~]# nginx -V
    nginx version: nginx/1.16.1
    built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
    built with OpenSSL 1.0.2k-fips  26 Jan 2017
    TLS SNI support enabled
    configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-pcre

    2.准备要编译的新模块

    找到安装nginx的源码根目录,如果没有的话下载新的源码

    比如要编译--with-http_realip_module这个模块

    cd /usr/local/nginx-1.16.1/
    ./configure  --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-pcre  --with-http_realip_module
    make     (千万别make install,否则就覆盖安装了)

    3.复制新的nginx二进制文件

    备份旧的nginx程序
    cd /usr/local/nginx/sbin
    mv nginx   nginx.bak4
    复制新的nginx程序
    cp  /usr/local/nginx-1.16.1/objs/nginx    /usr/local/nginx/sbin

    4.测试新的nginx

    [root@iZ2zehdwq9kcuuz64a2m22Z ~]# /usr/local/nginx/sbin/nginx  -t
    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

    5.查看nginx版本及编译情况

    [root@iZ2zehdwq9kcuuz64a2m22Z ~]# nginx -V
    nginx version: nginx/1.16.1
    built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
    built with OpenSSL 1.0.2k-fips  26 Jan 2017
    TLS SNI support enabled
    configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-pcre --with-http_realip_module

     nginx编译第三方模块

    1.下载第三方模块

    建立一个模块目录,因为添加模块后,那个目录要位置固定

    mkdir /usr/local/nginx/module
    wget https://github.com/openresty/echo-nginx-module/archive/v0.60.tar.gz
    tar  -xvf  v0.60.tar.gz  -C /usr/local/nginx/module

    2.编译新模块

    查看当前nginx编译模块

    [root@iZ2zehdwq9kcuuz64a2m22Z ~]# nginx -V
    nginx version: nginx/1.16.1
    built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
    built with OpenSSL 1.0.2k-fips  26 Jan 2017
    TLS SNI support enabled
    configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-pcre --with-http_realip_module

    找到nginx源码包目录,将原来的都填写上,最后–add-module是添加模块,指定模块文件夹位置即可

     ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_spdy_module --with-http_stub_status_module --with-pcre --add-module=/usr/local/nginx/module/echo-nginx-module-0.60/
    
    
    make      (不要install)

    3.替换新的nginx程序

    备份旧的nginx程序
    cd /usr/local/nginx/sbin
    mv nginx   nginx.bak4
    复制新的nginx程序
    cp  /usr/local/nginx-1.16.1/objs/nginx    /usr/local/nginx/sbin

    4.查看nginx编译情况

    /usr/local/nginx/sbin/nginx  -s reload
    /usr/local/nginx/sbin/nginx  -V

     

  • 相关阅读:
    Linux编程make命令(转)
    如何处理Global symbol * requires explicit package name编译错误,以及use strict用法
    6235与旧版本的区别
    Linux下动态链接库的使用
    MTK Socket学习——HTTP请求
    指针和指针的引用
    VC/MFC Combo Box控件的用法
    makefile教程
    常用数据类型使用转换详解
    Linux发送与接收信息
  • 原文地址:https://www.cnblogs.com/haoee/p/15497918.html
Copyright © 2011-2022 走看看