1. Start
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
startup code format: nginx installation directory address -c nginx configuration file address
For example:
[root@localhost ~]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
Two, stop
There are three ways to stop nginx:
1. Stop calmly
(1) Check the process number: ps -ef|grep nginx
[root@localhost ~]# ps -ef|grep nginx
(2) Kill the process: kill -quit xxxx
142804 is the number of the process
[root@localhost ~]# kill -quit 142804
2. Quick stop
(1) Check the process number: ps -ef|grep nginx
[root@localhost ~]# ps -ef|grep nginx
(2) Kill the process: kill -term xxxx/ kill -int xxxx
142804 is the number of the process
[root@localhost ~]# kill -term 142804
或
[root@localhost ~]# kill -int 142804
3. Force stop: pkill -9 nginx
[root@localhost ~]# pkill -9 nginx
3. Restart
1. Verify whether the nginx configuration file is correct
(1) Method 1: Enter the nginx installation directory sbin, enter the command ./nginx -t
to see the following display
nginx.conf syntax is ok
nginx.conf test is successful
The description configuration file is correct!
[root@localhost ~]# cd /usr/local/nginx/sbin
[root@localhost sbin]# ./nginx -t
(2) Method 2: Add -t before the startup command -c
[root@localhost sbin]# /usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
2. Restart the nginx service
(1) Method 1: Enter the nginx installation directory sbin, and enter the command ./nginx -s reload
[root@localhost ~]# cd /usr/local/nginx/sbin
[root@localhost sbin]# ./nginx -s reload
(2) Method 2: Find the current nginx process number, and then enter the command: kill -HUP process number to restart the nginx service