有多种方法可以查看Nginx是否正在运行。以下是其中的一些:
使用systemctl命令检查Nginx服务状态:
sudo systemctl status nginx
如果Nginx正在运行,则应该看到类似于以下内容的输出:
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/pb/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2022-06-27 08:15:30 UTC; 10h ago
Docs: man:nginx(8)
Process: 11711 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 11712 (nginx)
Tasks: 2 (pmit: 4915)
Memory: 4.3M
CGroup: /system.spce/nginx.service
├─11712 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
└─11713 nginx: worker process
检查Nginx进程是否正在运行:
ps aux | grep nginx
如果Nginx正在运行,则应该看到类似于以下内容的输出:
root 11712 0.0 0.7 139780 3916 ? Ss Jun26 0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 11713 0.0 0.9 140376 4872 ? S Jun26 0:00 nginx: worker process
检查Nginx监听的端口:
sudo netstat -tulpn | grep nginx
如果Nginx正在运行,则应该看到类似于以下内容的输出:
tcp6 0 0 :::80 :::* LISTEN 11712/nginx: maste
这表明Nginx正在监听80端口。