在 Debian 上排查 Nginx 故障,通常可以按“由外到内、由配置到运行”的思路来定位。下面是一套比较系统的排查流程。
systemctl status nginx
或
ps aux | grep nginx
常见情况:
active (running) → 服务正常failed → 启动失败(看日志)启动 / 重启:
systemctl start nginx
systemctl restart nginx
journalctl -u nginx -xe
tail -n 50 /var/log/nginx/error.log
常见错误:
Address already in use → 端口被占用permission denied → 权限问题no such file or directory → 路径错误unknown directive → 配置语法错误nginx -t
输出示例:
nginx: configuration file /etc/nginx/nginx.conf test is successful
如果失败,会指出具体文件和行号。
/etc/nginx/nginx.conf/etc/nginx/sites-enabled//etc/nginx/conf.d/ss -lntp | grep nginx
或
netstat -lntp | grep nginx
确认是否监听:
0.0.0.0:80:::800.0.0.0:443ss -lntp | grep ':80'
常见于:
iptables -L -n
# 或
nft list ruleset
如果是 ufw:
ufw status
curl -I http://127.0.0.1
curl -I http://your-domain.com
若本地通、外部不通 → 网络 / DNS / 防火墙问题
index 文件不存在autoindex offfastcgi_pass / proxy_pass 错误error_log /var/log/nginx/error.log debug;
然后:
nginx -s reload
nginx -t → 配置对不对systemctl status nginx → 服务起没起error.log → 真正报错在哪ss -lntp → 端口对不对curl → 本地能不能通如果你愿意,可以把 具体报错信息或 nginx -t 输出贴出来,我可以直接帮你定位是哪一类问题。