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

作者:佚名 上传时间:2019-04-30 版权申诉

首先查看现在环境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,如需转载请自行联系原作者

免责申明:文章和图片全部来源于公开网络,如有侵权,请通知删除 server@dude6.com

用户评论
相关推荐
nginx1.8.0版本平滑升级新版本1.9.7
首先查看现在环境nginx的版本为1.8.0 编译的参数只指定了安装路径; 1
Nginx平滑升级到最新版本
(一)简述: 早上收到nginx最新漏洞的通知,Nginx官方发布最新的安全公告,在Nginx范围过滤器中发现了一个安全问题(CVE-2017-7529),通过精心构造的恶意请求
Nginx平滑升级到最新版本
(一)简述: 早上收到nginx最新漏洞的通知,Nginx官方发布最新的安全公告,在Nginx范围过滤器中发现了一个安全问题(CVE-2017-7529),通过精心构造的恶意请求
Subversion1.9.7for MAC最新版本
Subversion-1.9.7forMAC10.12/13最新版本Subversion-1.9.7forMAC10.12/13最新版本
PKG
0B
2019-10-18 12:36
教你平滑升级Nginx版本.docx
LINUX操作系统、Nginx Web服务器、MySQL/MariaDB数据库服务器、PHP/Python/Perl... 等开发语言。
DOCX
16KB
2020-07-17 13:20
Android版本新版本升级
android1.6+eclipse
RAR
0B
2019-08-03 22:00
OpenResty 平滑升级
1、先去下载新版,当前最新版为“ngx_openresty-1.7.0.1” 2、开始升级 tar zxvf ngx_openresty-
nginx平滑升级
nginx平滑升级
TXT
0B
2019-08-17 19:26
升级程序最新版本
在原来程序上增加了设置升级参数功能。详细见readme.txt
RAR
0B
2019-01-02 08:35
FreeBSD如何升级到最新版本
FreeBSD是一款自由的类Unix操作系统,它的版本升级是非常方便的。本文将介绍如何将FreeBSD升级到最新版本,并提供一些示例代码和代码释义。FreeBSD版本升级升级FreeBSD需要使用
FreeBSD 13.0
FreeBSD 系统
2023-04-13 03:56