nginx 版本升级和添加模块详解

news/2024/7/4 8:19:26

版本升级

把1.16.0版本升级为1.18.0
查看本机现在版本为1.16.0
[root@localhost ]# /usr/local/nginx/sbin/nginx -v
nginx version: nginx/1.16.0

1,下载1.18.0的版本
[root@localhost ]# wget http://nginx.org/download/nginx-1.18.0.tar.gz
2,解压
[root@localhost ~]# tar xzf nginx-1.18.0.tar.gz
3,编译
[root@localhost ~]# cd nginx-1.18.0
查看编译的参数
[root@localhost ]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.16.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --group=nginx --user=nginx --sbin-path=/usr/local/nginx/sbin/nginx --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=/tmp/nginx/client_body --http-proxy-temp-path=/tmp/nginx/proxy --http-fastcgi-temp-path=/tmp/nginx/fastcgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-pcre --with-http_realip_module --with-stream
编译
[root@localhost objs]# ./configure --prefix=/usr/local/nginx --group=nginx --user=nginx --sbin-path=/usr/local/nginx/sbin/nginx --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=/tmp/nginx/client_body --http-proxy-temp-path=/tmp/nginx/proxy --http-fastcgi-temp-path=/tmp/nginx/fastcgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-pcre --with-http_realip_module --with-stream # --add-module=./echo-nginx-module-0.61 --add-module=./ngx_req_status-master

[root@localhost nginx-1.16.0]# make

查看编译的返回值是否正确
[root@localhost nginx-1.16.0]# $?
0
[root@localhost nginx-1.16.0]# make
按照原来的编译参数安装 nginx 的方法进行安装,只需要到 make,千万不要 make install 。如果make install 会将原来的配置文件覆盖

4,备份原 nginx 二进制文件

备份二进制文件和 nginx 的配置文件(期间nginx不会停止服务)
[root@localhost ~ ]# mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx_$(date +%F)
5,复制新的nginx二进制文件,进入新的nginx源码包
[root@localhost ~]# cp /usr/local/nginx-1.18.0/objs/nginx /usr/local/nginx/sbin/2
6,测试新版本的nginx是否正常
[root@localhost ~]# /usr/local/nginx/sbin/nginx -t
7,给nginx发送平滑迁移信号(若不清楚pid路径,请查看nginx配置文件)

[root@localhost ~]# kill -USR2 `cat /var/run/nginx.pid`

8,从容关闭旧的Nginx进程

[root@localhost ~]# kill -WINCH `cat /var/run/nginx.pid.oldbin`

9、此时不重载配置启动旧的工作进程

[root@localhost ~]# kill -HUP `cat /var/run/nginx.pid.oldbin`

10、结束工作进程,完成此次升级

[root@localhost ~]# kill -QUIT `cat /var/run/nginx.pid.oldbin`

11、验证Nginx是否升级成功

[root@localhost ~]# /usr/local/nginx/sbin/nginx -v
nginx version: nginx/1.18.0

升级完成

添加模块


http://www.niftyadmin.cn/n/3585852.html

相关文章

nginx 证书申请和证书的使用

1,证书申请 申请证书要有阿里云的域名 阿里云提供免费的证书,不需要人工审核,用来做测试是非常不错的选择,申请地址如下URL。 购买完了以后申请证书 证书签发之后,可以在列表中可以看到状态栏中为 已签发 &#xff0…

getopt和getopt_long函数

本文转自:http://blog.csdn.net/cashey1991/article/details/7942809 平时在写程序时常常需要对命令行参数进行处理,当命令行参数个数较多时,如果按照顺序一个一个定义参数含义很容易造成混乱,而且如果程序只按顺序处理参数的话&a…

'mysql.innodb_index_stats' doesn't exist when using LOCK TABLES问题原因及解决方法

前言 下面总结的是使用mysqldump备份整个数据库时的常见的一个报错的原因及解决方法。 报错如下 mysqldump: Got error: 1146: Table ‘mysql.innodb_index_stats’ doesn’t exist when using LOCK TABLES 执行导出数据库时报1146,mysql_innodb_table_stats显示没有…

数据Cocos2d-x常用功能-Cocos2d-x常用工具:计时器、数据读写、文件读写(共6部分)

第三阶段:常用功能5 1.Cocos2d-x计时器每一帧执行的时候执行一次#include "cocos2d.h"class HelloWorld : public cocos2d::Layer { private: cocos2d::LabelTTF *label; public: // theres no id in cpp, so we recommend returning…

lvs架构

lvs 4种模式 1、nat(网络地址转换模式) 2、dr(直接路由模式) 3、tun(隧道模式) 4、full-nat(双向转换模式) 1,nat(网络地址转换模式架构) 1、nat模式优势是,后端可以是任意支持tcp/ip的操作系统,缺点是响应时回包必须…

容器:用empty来代替检查size()是否为0

对于任意容器c,写下 if (c.size() 0)... 本质上等价于写下 if (c.empty())... 这就是例子。你可能会奇怪为什么一个构造会比另一个好,特别是事实上empty的典型实现是一个返回size是否返回0的内联函数。 你应该首选empty的构造,而且理由很…

nginx 代理 负载均衡 网站转接的用法

反向代理 1,准备两台nginx真实服务器 a、nginx-1 启动网站(内容)(作为网站服务器) b、nginx-2 启动代理程序 一、编辑nginx-2的配置文件 [rootnginx-server ~]# vim /etc/nginx/conf.d/default.conf server {server {listen 80; ser…

LNMP+zabbix监控平台搭建

前言 由于某个项目需要新搭建zabbix监控平台。于是就抽时间总结了zabbix搭建的流程及排错的详细流程。由于每个人的生产环境的差异,本文适用于参考。 实际上,使用yum安装配置LAMPzabbix更加的方便,快捷。但是,为了便于管理&#…