作为IT工程师,以下是几种检查Nginx状态的方法:
# 使用systemd (大多数现代Linux发行版)
systemctl status nginx
# 使用init.d (较旧系统)
service nginx status
ps aux | grep nginx
netstat -tulnp | grep nginx
# 或
ss -tulnp | grep nginx
nginx -t
如果启用了ngx_http_stub_status_module模块,可以通过以下URL查看:
http://your-server-ip/nginx_status
# 默认错误日志位置
tail -f /var/log/nginx/error.log
# 默认访问日志位置
tail -f /var/log/nginx/access.log
curl -I http://localhost
nginx -v # 显示版本
nginx -V # 显示版本和配置参数
nginx -T # 测试并显示所有有效配置
根据您的具体需求选择合适的检查方法,可以全面了解Nginx的运行状态。