• yum安装下的nginx,如何添加模块,和添加第三方模块


    背景:centos7下yum直接安装的nginx,添加新模块

    1、查看nginx版本模块
    nginx -V


    2、下载一个同版本的可编译的nginx
    cd /home/ngadm
    wget http://nginx.org/download/nginx-1.12.2.tar.gz
    tar zxvf nginx-1.12.2.tar.gz && cd nginx-1.12.2

    3、备份、备份、备份
    备份文件
    mv /usr/sbin/nginx /usr/sbin/nginx.20180720
    cp -r /etc/nginx /etc/nginx.20180720

    4、检查模块是否支持,比如这次添加 limit 限流模块 和 stream 模块:
    ./configure –help | grep limit

    ps:-without-http_limit_conn_module disable 表示已有该模块,编译时,不需要添加

    ./configure –help | grep stream

    ps:–with-stream enable 表示不支持,编译时要自己添加该模块

    根据第二步查到已有的模块,加上本次需新增的模块,那么最终结果如下:

    ./configure –user=nginx –group=nginx –prefix=/usr/share/nginx –sbin-path=/usr/sbin/nginx –modules-path=/usr/lib64/nginx/modules –conf-path=/etc/nginx/nginx.conf –error-log-path=/var/log/nginx/error.log –http-log-path=/var/log/nginx/access.log –with-stream –with-file-aio –with-ipv6 –with-http_auth_request_module –with-http_ssl_module –with-http_v2_module –with-http_realip_module –with-http_addition_module –with-http_xslt_module=dynamic –with-http_image_filter_module=dynamic –with-http_geoip_module=dynamic –with-http_sub_module –with-http_dav_module –with-http_flv_module –with-http_mp4_module –with-http_gunzip_module –with-http_gzip_static_module –with-http_random_index_module –with-http_secure_link_module –with-http_degradation_module –with-http_slice_module –with-http_stub_status_module –with-http_perl_module=dynamic –with-mail=dynamic –with-mail_ssl_module –with-pcre –with-pcre-jit –with-stream=dynamic –with-stream_ssl_module –with-debug

    以上编译时,如出现缺少依赖,一般需要安装以下模块,安装完再次编译:
    yum -y install libxml2 libxml2-dev libxslt-devel
    yum -y install gd-devel
    yum -y install perl-devel perl-ExtUtils-Embed
    yum -y install GeoIP GeoIP-devel GeoIP-data

    5、编译通过,继续验证
    继续输入:make -j2
    禁止:千万不要继续输入“make install”,以免现在的nginx出现问题
    以上完成后,会在objs目录下生成一个nginx文件,先验证:
    objs/nginx -t
    objs/nginx -V

    6、文件替换,并重启
    以上成功后:
    cp objs/nginx /usr/sbin/
    nginx -s reload

    重启:
    nginx -s stop && nginx

    补充:添加第三方模块时,先下载需要的模块,例如:echo模块
    cd /usr/local/src
    wget https://github.com/openresty/echo-nginx-module/archive/v0.61.tar.gz
    tar zxvf v0.61.tar.gz

    然后在编译时,加上模块的路径:
    ./configure –user=nginx –group=nginx –prefix=/usr/share/nginx –sbin-path=/usr/sbin/nginx –modules-path=/usr/lib64/nginx/modules –conf-path=/etc/nginx/nginx.conf –error-log-path=/var/log/nginx/error.log –http-log-path=/var/log/nginx/access.log –with-stream –with-file-aio –with-ipv6 –with-http_auth_request_module –with-http_ssl_module –with-http_v2_module –with-http_realip_module –with-http_addition_module –with-http_xslt_module=dynamic –with-http_image_filter_module=dynamic –with-http_geoip_module=dynamic –with-http_sub_module –with-http_dav_module –with-http_flv_module –with-http_mp4_module –with-http_gunzip_module –with-http_gzip_static_module –with-http_random_index_module –with-http_secure_link_module –with-http_degradation_module –with-http_slice_module –with-http_stub_status_module –with-http_perl_module=dynamic –with-mail=dynamic –with-mail_ssl_module –with-pcre –with-pcre-jit –with-stream=dynamic –with-stream_ssl_module –with-debug –add-module=/usr/local/src/echo-nginx-module-0.61

    后续的操作和 第5、6步一样
    ---------------------
    作者:zzy5066
    来源:CSDN
    原文:https://blog.csdn.net/zzy5066/article/details/81136273
    版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    C++学习(c++17)——2.X.使用string和string_view
    C++学习(c++17)——1.3一个小程序(part2.Datebase类)
    论++i + ++i + ++i
    C++学习(c++17)——1.3 一个小程序(part1.Employee类)
    C++学习(c++17)——1.2 稍微深入研究C++
    VS2019社区版关于Qt的设置
    C++学习(c++17)——1.1 C++基础知识
    2020杭电多校第五场
    2020杭电多校第四场
    2020杭电多校第三场
  • 原文地址:https://www.cnblogs.com/Gbeniot/p/10239558.html
Copyright © 2020-2023  润新知