Home > Operation and Maintenance > Linux Operation and Maintenance > How to check whether nginx is started in Linux

How to check whether nginx is started in Linux

青灯夜游
Release: 2019-06-17 15:52:33
Original
36721 people have browsed it

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.

How to check whether nginx is started in Linux

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
Copy after login

How to check whether nginx is started in Linux

Or use the following command to view the process ID directly.

ps -C nginx -o pid
Copy after login

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.

How to check whether nginx is started in Linux

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
Copy after login

How to check whether nginx is started in Linux

lsof -i:80
Copy after login

How to check whether nginx is started in Linux

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template