要查看 nginx 是否已启动,可使用以下步骤:通过 systemctl 命令检查状态:systemctl status nginx检查配置并查看 Nginx 是否正在运行:nginx -t检查 Nginx 是否监听端口 80:netstat -plnt | grep 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