怎么看nginx是否啟動

要查看 nginx 是否已啟動,可使用以下步驟:通過 systemctl 命令檢查狀態:systemctl status nginx檢查配置并查看 Nginx 是否正在運行:nginx -t檢查 Nginx 是否監聽端口 80:netstat -plnt | grep nginx

怎么看nginx是否啟動

如何查看 Nginx 是否已啟動?

要查看 Nginx 是否已啟動,請按照以下步驟操作:

使用 systemctl 命令

在終端中運行以下命令:

systemctl status nginx

輸出解釋:

  • 如果 Nginx 正在運行,輸出將顯示 “Active: active (running)”。
  • 如果 Nginx 未運行,輸出將顯示 “Active: inactive (dead)”。

使用 nginx -t 命令

在終端中運行以下命令:

nginx -t

輸出解釋:

  • 如果 Nginx 配置正確并正在運行,輸出將顯示 “the configuration file /etc/nginx/nginx.conf syntax is ok”。
  • 如果 Nginx 配置出現問題,輸出將顯示錯誤消息。

使用 netstat 命令

在終端中運行以下命令:

netstat -plnt | grep nginx

輸出解釋:

  • 如果 Nginx 正在監聽端口 80,輸出將顯示 “tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN”。
  • 如果 Nginx 未在端口 80 上監聽,則輸出將為空。

? 版權聲明
THE END
喜歡就支持一下吧
點贊7 分享