Get the App
SLTechnology News&Howtos  ›  Servers  › 

Sharing of implementation methods for smooth restart and upgrade of nginx

Shulou Source: shulou.com Published: 2022-06-02 04:55:59 09月17日 Update

Sometimes we need to restart the nginx service smoothly to prevent problems. Here is a simple summary for the convenience of friends in need.

If you change the Nginx configuration file (nginx.conf) and want to restart Nginx, you can also do so by sending a system signal to the Nginx main process. However, before restarting, make sure that the syntax of the Nginx configuration file (nginx.conf) is correct, otherwise Nginx will not load the new configuration file. You can determine whether the Nginx configuration file is correct by using the following command:

/ usr/local/webserver/nginx/sbin/nginx-t-c

/ usr/local/webserver/nginx/conf/nginx.conf

If the configuration file is incorrect, the screen will prompt for an error on which line of the configuration file:

[emerg]: unknowndirective "abc" inlusrllocaUwebserverlnginxjconflnginx.conf:55

Configurationfile/usr/local/webserver/nginx/conf/ nginx conf test failed

If the configuration file is correct, the screen prompts you with the following two lines of information:

The configuration file/usr/loca/webserver/nginx/conf/ http://www.bbqmw.net/qm_yeqm//nginx.conf syntax is ok

Configuration file/usr/local/webserver/nginx/conf/nginx.conf test is successful

At this point, you can restart Nginx smoothly.

The copy code is as follows:

/ usr/local/www/nginx/sbin/nginx-xs reloadx

Or:

The copy code is as follows:

Killx-HUP `cat / usr/local/www/nginx/logs/ nginx.pidx`

Here are some additions:

Smoothly restart kill-HUP `cat / usr/local/www/nginx/logs/ nginx.pid`

Smooth upgrade nginx

Cd / yujialin

Wget http://nginx.org/download/nginx-1.0.6.tar.gz

Tar zxvf nginx-1.0.6.tar.gz

Cd nginx-1.0.6

/ usr/local/www/nginx/sbin/nginx-V

Nginx: nginx version: nginx/1.0.4

Nginx: built by gcc 4.1.2 20080704 (Red Hat 4.1.2-50)

Nginx: configure arguments:-prefix=/usr/local/www/nginx-- with-pcre=/yujialin/pcre-8.12-- with-http_stub_status_module-- with-http_gzip_static_module

This step is to get the compilation parameters

. / configure-prefix=/usr/local/www/nginx-with-pcre=/yujialin/pcre-8.12-with-http_stub_status_module-with-http_gzip_static_module

Compile with the above paragraph

Then make, please don't make install.

After make, there is an extra nginx in the objs directory. This is the new version of the program.

Mv / usr/local/www/nginx/sbin/nginx / usr/ http://www.bbqmw.net/qm_yeqm//local/www/nginx/sbin/nginx-20110906

Cp objs/nginx / usr/local/www/nginx/sbin/nginx

/ usr/local/www/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 successfu

Make upgrade performs upgrad

After execution / usr/local/nginx/sbin/nginx-V

Nginx: nginx version: nginx/1.0.6

Nginx: built by gcc 4.1.2 20080704 (Red Hat 4.1.2-50)

Nginx: configure arguments:-prefix=/usr/local/www/nginx-- with-pcre=/yujialin/pcre-8.12-- with-http_stub_status_module-- with-http_gzip_static_module

Tags: File configuration smoothing code upgrade screen prompt compilation signal information parameter can be passed command done that is way sometimes friends directory program Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Docker macOS Redmi Shulou Technology