In the process of using Nginx, we may always need to modify the nginx configuration file, and then start or stop the nginx service continuously.
Here is a brief talk about the relevant command line of nginx.
Find the installation path of nginx
whereis nginx
This article /usr/local/nginx/sbin/ is the installation path of my local nginx
1. Start the nginx service
Execute the following command in the directory where nginx is located:
The following three start methods are available
1. Start one
cd /usr/local/nginx/sbin/
./nginx
2. Start Two
/usr/local/nginx/sbin/nginx
3. Start Three
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
2. View the running status of nginx
ps -ef | grep nginx
Display the current running status of nginx as follows:
3. Restart the nginx service
Both of the following restart methods are fine
1. Restart service one
cd /usr/local/nginx/sbin
./nginx -s reload
2. Restart service two
/usr/local/nginx/sbin/nginx -s reload /usr/local/nginx/conf/nginx.conf
4. Stop nginx service
First enter the directory where nginx is located. Under Linux, you can use whereis nginx to find the nginx installation directory, then cd to the directory where nginx is located and run the following command:
cd /usr/local/nginx/sbin/
./nginx -s stop
or
1. Check the nginx process number
2. Use the kill command
kill -9 1276 1278