当前位置:首页 > nginx > 正文

linux查看nginx是否启动(linux启动nginx命令)

  • nginx
  • 2024-03-20 22:29:20
  • 4288
用于检查 Nginx 是否正在运行的 Linux 命令

systemctl 状态 nginx


此命令将显示 nginx 服务的状态。 如果服务正在运行,您将看到以下输出:


nginx.service - nginx - high performance web server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor pre set: enabled)
Active: active (running) since Sat 2023-03-11 17:48:12 UTC; 4 days ago
Process: 6578 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 6580 (nginx)
CGroup: /system.slice/nginx.service
├─6580 nginx: master process /usr/sbin/nginx -g daemon on; master_process on
├─6607 nginx: worker process
└─6608 nginx: worker process
Mar 12 17:48:12 localhost.localdomain systemd[1]: Started nginx - high performance web server.

ps aux | grep nginx


此命令将列出所有正在运行的 nginx 进程。 如果 nginx 正在运行,您将看到类似以下的输出:


root 6580 0.0 0.0 65076 2436 ? Ssl 17:48 0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on
www-data 6607 0.0 0.0 64840 2328 ? S 17:48 0:00 nginx: worker process
www-data 6608 0.0 0.0 64840 2316 ? S 17:48 0:00 nginx: worker process

netstat -anp | grep nginx


此命令将列出 nginx 正在监听的端口。 如果 nginx 正在运行,您将看到类似以下的输出:


tcp 0 0 0.0.0.0:80 0.0.0.0: LISTEN 6580/nginx