zoukankan      html  css  js  c++  java
  • nginx针对yum安装nginx重编译

    1.查看nginx信息

    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.1.1c FIPS  28 May 2019 (running with OpenSSL 1.1.1g FIPS  21 Apr 2020)
    TLS SNI support enabled
    configure arguments: --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 --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-stream_ssl_preread_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_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-http_auth_request_module --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E'
    
    

    2.对现有的nignx进行备份

    mv /usr/sbin/nginx /usr/sbin/nginx.bak
    cp -r /etc/nginx /etc/nginx.bak
    

    3.下载一个同版本的nginx

      wget http://nginx.org/download/nginx-1.16.1.tar.gz -o /opt
      cd /opt
    
    1. 安装依赖(有些不用,我只是尽量全一些)
    yum -y install libxml2 libxml2-dev libxslt-devel gd-devel perl-devel perl-ExtUtils-Embed GeoIP GeoIP-devel GeoIP-data
    yum -y install  --skip-broken gcc gcc-c++ autoconf automake gperftools
    yum -y install --skip-broken zlib zlib-devel openssl-devel pcre-devel
    
    

    5.可以添加一些模块,或者第三方模块
    添加已有模块

      ./configure --help | grep limit  #查看limit模块是否可以安装。enable为可以直接添加
      https://github.com/cfsego/ngx_log_if/ github上下载测试的第三方模块,下载到/app目录
      unzip ngx_log_if-master.zip -d /app
    

    6.编译(在原文后面直接加上add module即可)

    ./configure --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 --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-stream_ssl_preread_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_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-http_auth_request_module --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E' --add-module=/app/ngx_log_if-master
    

    7.生成nginx二进制文件

    make -j2   #不要输入make install ,会替换现有nginx,造成事故
    

    8.测试

    objs/nginx -t 
    objs/nginx -V
    cp objs/nginx /usr/sbin/ 
    nginx -t 
    nginx -s reload
    
    

    替换完成,这个时候记得看下web网站是否运行正常,模块是否正常

  • 相关阅读:
    【ABAP】
    【Ebs】-日记账导入优化
    【EBS】-日记账审批相关知识点
    【LINUX】cron知识小结
    【Oracle】物化视图相关SQL
    【Ebs】EBS12.2.7 REST ISG的配置
    【Oracle】Windows上Oracle数据库的安装
    【EBS】菜单的复制脚本
    《我们内心的冲突》(卡伦•霍尼)读书笔记
    魔方攻略
  • 原文地址:https://www.cnblogs.com/dinghc/p/14830620.html
Copyright © 2011-2022 走看看