Home  >  Article  >  Operation and Maintenance  >  What is the method to start and stop nginx in Linux system

What is the method to start and stop nginx in Linux system

WBOY
WBOYforward
2023-05-19 09:34:055503browse

What is the method to start and stop nginx in Linux system

Startup

Startup code format: nginx installation directory address -c nginx configuration file address

For example:

 [root@LinuxServer sbin]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

Stop

There are three ways to stop nginx:

  • Stop calmly

1. Check the process number

 [root@LinuxServer ~]# ps -ef|grep nginx

What is the method to start and stop nginx in Linux system

 2. Kill the process

 [root@LinuxServer ~]# kill -QUIT 2072

What is the method to start and stop nginx in Linux system

  • ##Quick stop

1. Check the process number

 [root@LinuxServer ~]# ps -ef|grep nginx

What is the method to start and stop nginx in Linux system

2. Kill the process

 [root@LinuxServer ~]# kill -TERM 2132
 或 [root@LinuxServer ~]# kill -INT 2132

What is the method to start and stop nginx in Linux system

  • Force stop

  •  [root@LinuxServer ~]# pkill -9 nginx
Restart

1. Verify whether the nginx configuration file is correct

Method 1: Enter the nginx installation directory sbin and enter the command ./nginx - t
See the following display nginx.conf syntax is ok

nginx.conf test is successful

It means the configuration file is correct!

What is the method to start and stop nginx in Linux system

Method 2: Add -t before the start command -c

What is the method to start and stop nginx in Linux system

2. Restart the Nginx service

Method 1: Enter the nginx executable directory sbin and enter the command ./nginx -s reload

What is the method to start and stop nginx in Linux system

Method 2: Find the current nginx process number and enter Command: kill -HUP process number to restart nginx service

What is the method to start and stop nginx in Linux system

The above is the detailed content of What is the method to start and stop nginx in Linux system. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete