Enable, disable, and restart nginx. Enable, disable, and restart nginx.

Source: Internet
Author: User

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.