background:Since the nginx version in the load balancing test server is too low and there is a security vulnerability, after querying the relevant vulnerability repair information, it is necessary to upgrade the nginx version to repair the vulnerability. Nginx smooth upgrade solution1. Introduction to the version used in this case Old version nginx-1.12.2.tar.gz New version nginx-1.20.1.tar.gz 2. nginx-1.12.2 is the current running version Set port 8080 and modify the homepage index.html. You can still access it after a smooth upgrade. 3. Unzip the new version nginx-1.20.1.tar.gz, compile and install it in the directory of the old version nginx-1.12.2, run the original nginx.conf configuration file, and execute as follows ./configure --prefix=/usr/local/nginx-1.12.2 --conf-path=/usr/local/nginx-1.12.2/nginx.conf --pid-path=/usr/local/nginx-1.12.2/nginx.pid --user=ngadm --group=ngadm --with-http_stub_status_module --without-http_rewrite_module make && make install 4. After completion, version 1.20.1 will automatically generate a new nginx binary file in the original sbin directory, and the old nginx will be automatically replaced with nginx.old 5. Smooth upgrade Nginx has very powerful control over processes and can control processes through signal instructions. Commonly used signals are:
According to the nginx process control signal, execute as follows: kill -USR2 38323 (the old process PID is 38323) ps -ef |grep nginx Switch to the new master process and close the old worker process. Note that the old master process still exists. Execute as follows: kill –WINCH 38323 (the old process PID is 38323) ps -ef |grep nginx Check the current version sbin/nginx -v The upgrade was completed successfully. Note: At this time, the masterPID of the new version of nginx is 41063. At the same time, the master process of the old version (the old process PID is 38323) also exists. If you do not need to roll back, you can execute the old process exit operation as follows: kill –QUIT 38323 Fallback stepsThere are two types of rollback operations: 1. Back up the old version of nginx in advance. If there is a problem, just copy the old version back to the /usr/local directory and restart the old version of nginx. Execute as follows: killall nginx cp nginx-1.12.2.bak nginx-1.12.2 /usr/local/nginx-1.12.2/sbin/nginx –c /usr/local/nginx-1.12.2/nginx.conf Check nginx status ps –ef |grep nginx 2. When the master process of the new version of nginx and the master process of the old version exist at the same time, execute the following: Switch back to the old version of the master process kill -HUP old masterPID Close the master process of the new version of nginx, and change the nginx.old (old version nginx binary file) in the original sbin directory back to nginx to manage nginx. kill -WINCH new masterPID kill -QUIT new masterPID cp /usr/local/nginx-1.12.2/sbin/nginx.old /usr/local/nginx-1.12.2/sbin/nginx Confirm again that the nginx version has returned to the original version sbin/nginx -v SummarizeThis is the end of this article about the smooth upgrade solution for Nginx versions. For more relevant content about smooth upgrade of Nginx versions, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Detailed usage of MYSQL row_number() and over() functions
Basic Use <!DOCTYPE html> <html lang=&qu...
This article example shares the specific code of ...
VNC is a remote desktop protocol. Follow the inst...
1.MySQL version [root@clq system]# mysql -v Welco...
Preface During development, we often encounter va...
I often need to change nginx configuration at wor...
When it comes to styling our web pages, we have t...
Table of contents Changes in the life cycle react...
This article example shares the specific code of ...
Use self:: or __CLASS__ to get a static reference...
I have been in contact with PHP for so long, but ...
Using c3p0 Import the c3p0jar package <!-- htt...
In order to improve user experience and ease of us...
Need to know how many days there are before an im...
This article shares the specific code of Vue.js t...