How to start, stop and reload using nginx

(*-*)浩
Release: 2019-11-30 11:42:11
Original
5144 people have browsed it

How to start, stop and reload using nginx

To start nginx, run the executable file. When nginx is started, it can be controlled by calling the executable file with the -s parameter.

Use the following syntax: (Recommended learning: nginx use )

Rrree

signal may be one of the following :

stop - Quickly shut down the service

quit - Normally shut down the service

reload - Reload the configuration file

reopen - Reopen the log file

For example, to stop the nginx process by waiting for the worker process to finish servicing the current request, you can execute the following command:

nginx -s signal
Copy after login

Note: This command should be executed under the same user who started nginx.

Changes in the configuration file will not be applied until the command to reconfigure the command is sent to nginx or restarted.

To reload the configuration file, please execute:

nginx -s quit
Copy after login

When the main process receives the signal to reload the configuration, it will check the syntax validity of the new configuration file, and try to apply the configuration provided there. If this is successful, the master process will start new worker processes and send messages to the old worker processes requesting them to shut down.

Otherwise, the main process rolls back the changes and continues to use the old configuration. The old worker process, upon receiving the shutdown command, stops accepting new connections and continues to maintain current requests until all these requests are maintained. After that, the old worker process exits.

You can also use Unix tools (such as kill utility) to send signals to the nginx process. In this case, the signal is sent directly to the process with the given process ID. By default, the process ID of the nginx main process is written to nginx.pid in the directory /usr/local/nginx/logs or /var/run.

For example, if the main process ID is 1628, and sending the QUIT signal causes nginx to shut down normally, please execute:

nginx -s reload
Copy after login

To get a list of all running nginx processes , you can use the ps command, for example, in the following way:

kill -s QUIT 1628
Copy after login

The above is the detailed content of How to start, stop and reload using nginx. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template