nginx1.8.0版本平滑升级新版本1.9.7

简介:

首先查看现在环境nginx的版本为1.8.0 编译的参数只指定了安装路径;

1
2
3
4
[root@localhost sbin] # ./nginx -V
nginx version: nginx /1 .8.0
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC)
configure arguments: --prefix= /usr/local/nginx

平滑升级步骤如下:

下载nginx1.9.7版本,解压并进入解压后的目录

1
2
3
4
[root@localhost ~] # wget -P /usr/local/src/  http://nginx.org/download/nginx-1.9.7.tar.gz
[root@localhost ~] # cd /usr/local/src/ 
[root@localhost src] # tar -zxvf nginx-1.9.7.tar.gz  
[root@localhost src] # cd nginx-1.9.7


编译安装之前查看nginx进程ID信息:

1
2
3
4
[root@localhost nginx-1.9.7] # ps -ef |grep nginx
root       894     1  0 16:06 ?        00:00:00 nginx: master process  /usr/local/nginx/sbin/nginx  -c  /usr/local/nginx/conf/nginx .conf
nobody     896   894  0 16:06 ?        00:00:00 nginx: worker process                                          
nobody     897   894  0 16:06 ?        00:00:00 nginx: worker process

编译安装:指定用户www 支持ssl 支持pcre 支持状态查询 支持静态压缩模块;

1
[root@localhost nginx-1.9.7] # ./configure --user=www --group=www --prefix=/usr/local/nginx/ --with-pcre --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module

编译安装后可以echo $?查看是否成功,成功后只需要执行make,不需要make install;

1
[root@localhost nginx-1.9.7] # make

平滑升级,先移走现有的nginx二进制文件

1
[root@localhost nginx-1.9.7] # mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old

拷贝新生成的nginx二进制文件到指定目录

1
[root@localhost nginx-1.9.7] # cp objs/nginx /usr/local/nginx/sbin/


执行升级命令

1
2
3
4
5
6
7
8
[root@localhost nginx-1.9.7] # make upgrade
/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
kill  -USR2 ` cat  /usr/local/nginx//logs/nginx .pid`
sleep  1
test  -f  /usr/local/nginx//logs/nginx .pid.oldbin
kill  -QUIT ` cat  /usr/local/nginx//logs/nginx .pid.oldbin`


查看版本,发现已经是1.9.7版本,编译的参数也存在;

1
2
3
4
5
6
[root@localhost nginx-1.9.7] # /usr/local/nginx/sbin/nginx -V
nginx version: nginx /1 .9.7
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --user=www --group=www --prefix= /usr/local/nginx/  --with-pcre --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module


创建www用户

1
[root@localhost nginx-1.9.7] # useradd -s /sbin/nologin -M www


查看nginx进程 PID已经更改

1
2
3
4
[root@localhost sbin] # ps -ef |grep nginx
root      3814     1  0 16:23 ?        00:00:00 nginx: master process  /usr/local/nginx/sbin/nginx  -c  /usr/local/nginx/conf/nginx .conf
nobody    3815  3814  0 16:23 ?        00:00:00 nginx: worker process                                          
nobody    3816  3814  0 16:23 ?        00:00:00 nginx: worker process


修改nginx.conf配置文件,更改用户和用户组为www用户,保存退出,重启nginx服务;

1
2
3
4
[root@localhost conf] # ps -ef |grep nginx
root      3814     1  0 16:23 ?        00:00:00 nginx: master process  /usr/local/nginx/sbin/nginx  -c  /usr/local/nginx/conf/nginx .conf
www       4200  3814  0 16:48 ?        00:00:00 nginx: worker process                                          
www       4201  3814  0 16:48 ?        00:00:00 nginx: worker process



nginx版本平滑升级结束;





本文转自 模范生 51CTO博客,原文链接:http://blog.51cto.com/mofansheng/1744062,如需转载请自行联系原作者

目录
相关文章
|
1月前
|
应用服务中间件 Linux 网络安全
CentOS 7.4源码编译nginx1.12 并且隐藏nginx的版本
CentOS 7.4源码编译nginx1.12 并且隐藏nginx的版本
17 0
|
5月前
|
应用服务中间件 网络安全 nginx
nginx 常用命令 |升级到1.20.1版本 | 如何更换 Nginx SSL 证书
nginx 常用命令 |升级到1.20.1版本 | 如何更换 Nginx SSL 证书
173 0
|
3月前
|
存储 Linux 应用服务中间件
VMware安装无GUI版本的Linux(CentOS7)——安装Nginx示例demo
VMware安装无GUI版本的Linux(CentOS7)——安装Nginx示例demo
124 1
|
7月前
|
前端开发 Java jenkins
Jenkins+Gitlab+Nginx+SonarQube+Maven编译Java项目自动发布与基于tag版本回退
Jenkins+Gitlab+Nginx+SonarQube+Maven编译Java项目自动发布与基于tag版本回退
255 0
|
7月前
|
Java jenkins 应用服务中间件
Jenkins+Gitlab+Nginx+Maven编译Java项目自动发布与基于tag版本回退(重复构建问题已解决)
Jenkins+Gitlab+Nginx+Maven编译Java项目自动发布与基于tag版本回退(重复构建问题已解决)
|
7月前
|
jenkins 应用服务中间件 持续交付
Jenkins+Gitlab+Nginx实现自动发布与回退基于tag版本的静态项目(解决重复构建问题)
Jenkins+Gitlab+Nginx实现自动发布与回退基于tag版本的静态项目(解决重复构建问题)
|
8月前
|
负载均衡 应用服务中间件 Linux
CentOS 系列版本搭建 Nginx 服务
Nginx 是一个广泛使用的Web服务器和反向代理服务器。 反向代理和负载均衡:Nginx支持反向代理和负载均衡,能够分发请求到多个后端服务器,提高了可用性和性能。 SSL/TLS支持:Nginx支持SSL/TLS协议,使您能够配置HTTPS并提供安全的数据传输。 低资源消耗:Nginx设计得非常轻量,占用较少的内存和CPU资源,因此在资源受限的环境中表现出色。 简单的配置:Nginx的配置文件易于理解和维护,使管理员能够快速进行配置更改。
70 1
|
10月前
|
网络协议 Java 关系型数据库
Linux常用命令大全(极简速查版本)(包含操作nginx、mysql)
Linux常用命令大全(极简速查版本)(包含操作nginx、mysql)
94 0
|
10月前
|
应用服务中间件 Shell nginx
Shell脚本:一键安装Nginx服务,用户可自定义Nginx版本
Shell脚本:一键安装Nginx服务,用户可自定义Nginx版本
256 0