可以通過以下方法查看 nginx 運行狀態:nginx -t:檢查配置文件語法是否正確。nginx -V:顯示 nginx 版本和其他編譯信息。service nginx status:查看 nginx 服務的運行狀態(適用于 linux 系統)。ps -ef | grep nginx:查找正在運行的 nginx 進程。netstat -nlp | grep nginx:查看 nginx 監聽的端口和地址。
nginx 運行狀態查看
如何查看 nginx 運行狀態?
使用以下命令之一:
- nginx -t: 檢查 nginx 配置文件語法是否正確,而不啟動 nginx。
- nginx -V: 顯示 nginx 版本和其他編譯信息,而不啟動 nginx。
- service nginx status: 查看系統服務中 nginx 的運行狀態(適用于 Linux 系統)。
- ps -ef | grep nginx: 查找所有正在運行的 nginx 進程,并顯示其狀態和其他信息。
- netstat -nlp | grep nginx: 查看 nginx 正在監聽哪些端口和地址。
詳細解釋:
nginx -t
此命令檢查 nginx 配置文件(通常位于 /etc/nginx/nginx.conf)的語法。如果配置文件正確,將顯示以下消息:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
nginx -V
此命令顯示 nginx 版本以及有關其編譯選項和其他信息。
service nginx status
此命令適用于 Linux 系統,它顯示 nginx 服務的運行狀態。輸出通常如下所示:
nginx is running (pid 12345)
ps -ef | grep nginx
此命令顯示系統中所有正在運行的 nginx 進程。輸出類似于:
root 12345 15122 15:02 ? 00:00:05 nginx: master process /usr/sbin/nginx -g daemon on; master_process on; root 12346 15125 15:02 ? 00:00:00 nginx: worker process
netstat -nlp | grep nginx
此命令顯示 nginx 監聽的端口和地址。輸出通常如下所示:
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN tcp 0 0 :::80 :::* LISTEN
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END