在 Debian 上调试 Nginx,通常可以按下面几个层次来做:看状态 → 看日志 → 测配置 → 抓请求 → 查系统。
systemctl status nginx
或
ps aux | grep nginx
nginx -t
常见错误:
duplicate locationunknown directiveSSL certificate errortail -f /var/log/nginx/error.log
tail -f /var/log/nginx/access.log
如果日志为空,说明请求没到 Nginx(防火墙 / DNS / 端口问题)
ss -tlnp | grep nginx
或
netstat -tlnp | grep nginx
常见端口:
ufw status
允许端口:
ufw allow 80
ufw allow 443
iptables -L -n
ls -l /etc/nginx/sites-enabled/
在 nginx.conf 或 server 块中:
error_log /var/log/nginx/error.log debug;
然后:
nginx -t
systemctl reload nginx
curl -I http://localhost
curl -v http://localhost
HTTPS:
curl -kv https://localhost
systemctl status php-fpm
检查:
fastcgi_pass unix:/run/php/php-fpm.sock;
proxy_pass http://127.0.0.1:3000;
检查后端是否运行:
curl http://127.0.0.1:3000
Debian 默认不用 SELinux,但可确认:
getenforce
nginx -t
systemctl restart nginx
tail -f /var/log/nginx/error.log
ss -tlnp | grep nginx
curl -v http://localhost
如果你愿意,可以告诉我:
我可以直接帮你定位具体原因。