Enable, disable, and restart nginx. Enable, disable, and restart nginx.
1. Start
[Root @ localhost local] # nginx/sbin/nginx # Start [root @ localhost local] # nginx/sbin/nginx-t # Check whether the configuration file is correct nginx: the configuration file/usr/local/nginx/conf/nginx. conf syntax is oknginx: configuration file/usr/local/nginx/conf/nginx. conf test is successful [root @ localhost local] # netstat-ntlpActive Internet connections (only servers) proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0: 80 0.0.0.0: * LISTEN 2756/nginx
2. Stop
[Root @ localhost sbin] # ps-ef | grep nginx # query the nginx main program number and find the master process in the process list. Its number is the master process number. Root28111 0 :52? 00:00:00 nginx:MasterProcess./nginxnobody 2838 2811 0? 00:00:00 nginx: worker processroot 27504 2707 0 00:00:00 pts/0 grep nginx [root @ localhost sbin] # kill-quit 2811 # Stop nginx with ease [root @ localhost sbin] # ps-ef | grep nginx root 27513 2707 0 00:00:00 pts/0 grep nginx
Stop kill-TERM master process number quickly
Force stop kill-9 nginx
3. Restart
If you change the configuration, restart Nginx. Do you need to disable Nginx before enabling Nginx? It can send signals to Nginx and restart smoothly.
Smooth restart command:
Kill-HUP master process number or process number file path
Or use
/Usr/nginx/sbin/nginx-s reload
Note: After modifying the configuration file, it is best to check whether the modified configuration file is correct to avoid Nginx errors after restart, which may affect the stable running of the server. The command to determine whether the Nginx configuration is correct is as follows:
Nginx-t-c/usr/nginx/conf/nginx. conf
Or
/Usr/nginx/sbin/nginx-t