Home >Operation and Maintenance >Linux Operation and Maintenance >How to check whether nginx is started in Linux
Nginx is a high-performance reverse proxy server. It is now generally used as the first-layer proxy for our website or other web services. The first thing a user requests in a browser is the Nginx service. If the Nginx service does not start or ends abnormally, it will affect the normal use of the web service. So how to check whether nginx is started? The following article will introduce to you how to check whether Nginx is started in Linux. I hope it will be helpful to you.
Method 1: Judge by process
Every Linux application will generate a process, then We can determine 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, use the following command to see whether the Nginx process exists.
ps -ef | grep nginx
Or use the following command to view the process ID directly.
ps -C nginx -o pid
This method of directly returning the pid is more suitable for use in combination with other programs. For example, executing this command in a shell/python script to get the pid, and then judging whether Nginx is started based on the pid.
Method 2: Determine by port
You can check whether there is Nginx on a certain port The process is running to determine whether Nginx is started.
If Nginx is running on port 80, you can use the following command to determine whether Nginx is started.
netstat -anp | grep :80
lsof -i:80
The above is the detailed content of How to check whether nginx is started in Linux. For more information, please follow other related articles on the PHP Chinese website!