Home > Article > Operation and Maintenance > 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 )
Rrreesignal 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
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
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
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
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!