Nginx1.8.0 smooth upgrade to new version 1.9.7

  • 2020-05-10 23:29:19
  • OfStack

  first looks at the version of nginx now compiled for 1.8.0, which only specifies the installation path.


[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

Smooth upgrade steps are as follows:

Download nginx1.9.7, unzip and enter the unzipped directory


[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

View nginx process ID information before compiling and installing:


[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

Compile and install: specify www support ssl support pcre support state query support static compression module;


[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 $? Check whether it is successful. After success, only make needs to be executed, not make install.


[root@localhost nginx-1.9.7]# make

Smooth upgrade, first remove the existing nginx2 base file


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

Copy the newly generated nginx2 base file to the specified directory


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

Execute the upgrade command


[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`

When you look at the version, you can see that it is version 1.9.7, and the parameters for compilation also exist.


[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

Create an www user


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

View nginx process PID has changed


[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
0

Modify the nginx.conf configuration file, change the user and user group to www users, save exit, and restart nginx service;


[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

Nginx1.8.0 version smooth upgrade new version 1.9.7 to introduce you here, I hope to help you!


Related articles: