有多種方法可以查看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端口。