Ubuntu查看nginx运行状态
时间: 2023-12-28 08:06:11 浏览: 135
Nginx中配置开启Nginx Status来查看服务器运行状态
你可以使用以下命令来查看 Nginx 运行状态:
1. 查看 Nginx 服务是否在运行:
```
sudo systemctl status nginx
```
如果 Nginx 正在运行,你应该会看到输出类似如下的信息:
```
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2021-05-31 20:18:51 UTC; 1 weeks 0 days ago
Docs: man:nginx(8)
Process: 1668 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 1664 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 1672 (nginx)
Tasks: 2 (limit: 1146)
Memory: 2.9M
CGroup: /system.slice/nginx.service
├─1672 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
└─1673 nginx: worker process
```
2. 查看 Nginx 监听的端口:
```
sudo netstat -tulpn | grep nginx
```
这将会列出所有正在监听的端口,如果 Nginx 正在监听 80 和 443 端口,你应该会看到类似如下的输出:
```
tcp6 0 0 :::80 :::* LISTEN 1672/nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
tcp6 0 0 :::443 :::* LISTEN 1672/nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
```
阅读全文