Home  >  Article  >  Operation and Maintenance  >  How to check if nginx is started?

How to check if nginx is started?

步履不停
步履不停Original
2019-06-21 10:04:498017browse

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 the Nginx Tutorial column 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!

Statement:
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