Starting Nginx
| |
| |
Check whether the configuration is correct.
Stopping Nginx
Stopping is done by sending signals to the nginx process (for more about signals, refer to Linux documentation).
Step 1: Find the nginx master process ID
| |
Find the master process in the process list – its number is the master process ID.
Step 2: Send a signal
Graceful shutdown:
1kill -QUIT master_process_idFast shutdown:
1kill -TERM master_process_idForced shutdown:
1pkill -9 nginx
Additionally, if the pid file path is configured in nginx.conf, that file contains the Nginx master process ID. If not specified, it is stored in nginx’s logs directory. With the pid file, you don’t need to look up the master process ID first and can send signals to Nginx directly:
| |
Graceful Restart
If you changed the configuration, do you need to stop Nginx and start it again? No – you can send a signal to Nginx for a graceful restart.
Graceful restart command:
| |
Or use:
| |
Note: After modifying the configuration file, it’s best to check whether the modified configuration is correct first, to avoid errors after restart that could affect server stability. The command to check Nginx configuration:
| |
Or:
| |