怎么查看nginx是否启动
时间: 2023-11-08 12:08:07 浏览: 87
nginx启动,停止,查看状态,重载脚本
5星 · 资源好评率100%
可以使用以下命令来查看nginx是否启动:
1. 使用ps命令查看nginx进程是否存在:
```
ps -ef | grep nginx
```
如果nginx进程存在,则会显示类似以下的结果:
```
root 9362 1 0 10:09 ? 00:00:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 9363 9362 0 10:09 ? 00:00:00 nginx: worker process
```
2. 使用systemctl命令检查nginx服务的状态:
```
systemctl status nginx
```
如果nginx服务正在运行,则会显示类似以下的结果:
```
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2021-08-23 10:09:29 CST; 7h ago
Docs: man:nginx(8)
Process: 9361 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 9362 (nginx)
Tasks: 2 (limit: 4915)
CGroup: /system.slice/nginx.service
├─9362 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
└─9363 nginx: worker process
Aug 23 10:09:29 ubuntu systemd[1]: Starting A high performance web server and a reverse proxy server...
Aug 23 10:09:29 ubuntu systemd[1]: Started A high performance web server and a reverse proxy server.
```
如果nginx服务没有运行,则会显示类似以下的结果:
```
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Mon 2021-08-23 10:09:29 CST; 7h ago
Docs: man:nginx(8)
Process: 9361 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Aug 23 10:09:29 ubuntu systemd[1]: Starting A high performance web server and a reverse proxy server...
Aug 23 10:09:29 ubuntu systemd[1]: Started A high performance web server and a reverse proxy server.
```
阅读全文