zoukankan      html  css  js  c++  java
  • Nginx如何重新编译添加模块

    1.查看nginx支持的模块

    nginx -V

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

    2.nginx平滑升级

    1.重新编译nginx

    ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_slice_module&&make
    

    2.备份二进制文件,用新版的替换
    新的nginx 二进制文件在objs目录下

    3确保配置文件正确(-t)

    4.发送USR2信号,Nginx会启动一个新版本的master进程和对应工作进程

    [root@www sbin]# ps aux|grep nginx
    root      3737  0.0  0.1  46116  2324 ?        Ss   May22   0:00 nginx: master process /usr/local/nginx/sbi
    root      6262  0.0  0.0 112712   992 pts/1    R+   21:58   0:00 grep --color=auto nginx
    www      31013  0.0  0.2  49340  4656 ?        S    Jun03   0:06 nginx: worker process
    [root@www sbin]# kill -USR2 3737
    [root@www sbin]# ps aux|grep nginx
    root      3737  0.0  0.1  46116  2324 ?        Ss   May22   0:00 nginx: master process /usr/local/nginx/sbin/nginx
    root      6373  0.0  0.1  45984  3728 ?        S    21:58   0:00 nginx: master process /usr/local/nginx/sbin/nginx
    www       6374  0.0  0.1  48476  2028 ?        S    21:58   0:00 nginx: worker process
    root      6400  0.0  0.0 112712   992 pts/1    R+   21:59   0:00 grep --color=auto nginx
    www      31013  0.0  0.2  49340  4656 ?        S    Jun03   0:06 nginx: worker process
    

    5.向旧的Nginx主进程(master)发送WINCH信号,它会逐步关闭自己的工作进程(主进程不退出),这时所有请求都会由新版Nginx处理

    [root@www sbin]# kill -WINCH 3737
    [root@www sbin]# ps aux|grep nginx
    root      3737  0.0  0.1  46116  2324 ?        Ss   May22   0:00 nginx: master process /usr/local/nginx/sbin/nginx
    root      6373  0.0  0.1  45984  3728 ?        S    21:58   0:00 nginx: master process /usr/local/nginx/sbin/nginx
    www       6374  0.0  0.1  48476  2028 ?        S    21:58   0:00 nginx: worker process
    root      6758  0.0  0.0 112712   988 pts/1    R+   22:00   0:00 grep --color=auto nginx
    

    6.发送QUIT信息

    [root@www sbin]# kill -QUIT 3737
    [root@www sbin]# ps aux|grep nginx
    root      6373  0.0  0.1  45984  3728 ?        S    21:58   0:00 nginx: master process /usr/local/nginx/sbin/nginx
    www       6374  0.0  0.1  48476  2028 ?        S    21:58   0:00 nginx: worker process
    root      7045  0.0  0.0 112712   992 pts/1    R+   22:02   0:00 grep --color=auto nginx
    

    7.如果需要回滚,发送HUP信号(在6之前操作)

    [root@localhost ~]# kill -HUP 3737
    
  • 相关阅读:
    DotNetty是微软的Azure团队,使用C#实现的Netty的版本发布
    C# 与 .NET Framework 对应关系
    C# 基于Directshow.Net lib库 USB摄像头使用DirectShow.NET获取摄像头视频流
    Actor模型的状态(State)+行为(Behavior)+邮箱(Mailbox)
    c# 无法加载DLL:找不到指定的模块(异常来自HRESULT:0X8007007E)
    管道式编程(Pipeline Style programming)
    Word文档转Markdown插件(Windows)
    纯Java实现定时任务(转)
    Spring MVC使用Schedule实现定时任务
    Spring Boot使用Schedule实现定时任务
  • 原文地址:https://www.cnblogs.com/feng0919/p/13338131.html
Copyright © 2011-2022 走看看