Home>Article>Operation and Maintenance> How to check if nginx is started?
Nginx is a high-performance reverse proxy server. Now it is generally used as the first-layer proxy for our website or other web services. The Nginx service is the first thing that users go through when making browser requests.
If the Nginx service does not start or ends abnormally, it will affect the normal use of the Web service.
Now I will share the process record of checking whether Nginx is started in Linux.
Tools/Materials
Linux
Nginx
Judge by process
The first method:View the process list and filter
Every Linux application will generate a process, then we can judge whether the Nginx process is started by checking whether it exists.
Use ps -ef to list the process, and then filter it through grep.
For example: ps -ef | grep nginx You can see whether the Nginx process exists.
Second method:View the process id directly
ps -C nginx -o pid
This method of directly returning the pid is more suitable for following Use it in combination with other programs, such as executing this command in a shell/python script to get the pid, and then use the pid to determine whether Nginx is started.
It is recommended to use this method.
END
Judge by port
The third method:Use the netstat command
If we Nginx runs on port 80, then you can use the netstat -anp | grep :80 command to determine whether Nginx is started.
Fourth method:Use the lsof command
lsof -i:80 You can also check whether there is a process running on port 80.
For more Nginx related technical articles, please visit theNginx Tutorialcolumn to learn!
The above is the detailed content of How to check if nginx is started?. For more information, please follow other related articles on the PHP Chinese website!