网站突然无法访问可能由多种原因导致。本文按照排查优先级,从网络层到应用层逐步排查,帮你快速定位问题。
先确认是所有人都无法访问,还是仅自己无法访问:
isitdown.site 或 downdetector.com 检查网站全球可达性# 查看域名解析结果
nslookup yourdomain.com
dig yourdomain.com
# 确认解析到的IP是否是VPS的IP
# 如果解析错误,检查DNS记录配置
DNS问题参考域名解析失败排查教程。
# Ping VPS IP
ping 你的VPS_IP
# 检查80/443端口是否开放
telnet 你的VPS_IP 80
telnet 你的VPS_IP 443
curl -I http://你的VPS_IP
如果Ping不通,参考SSH连接排查指南中的IP检查部分。
# 检查Nginx状态
systemctl status nginx
# 如果Nginx已停止,启动并查看错误
systemctl start nginx
# 如果启动失败,检查配置
nginx -t
# 检查Nginx错误日志
tail -50 /var/log/nginx/error.log
# 常见Nginx启动失败原因:
# 1. 配置文件语法错误
# 2. 端口被占用:lsof -i :80
# 3. SSL证书过期或路径错误
# 检查PHP-FPM状态
systemctl status php8.2-fpm
# 启动PHP-FPM
systemctl start php8.2-fpm
# 检查PHP-FPM日志
tail -50 /var/log/php8.2-fpm.log
# 测试PHP是否正常
php -v
echo "<?php phpinfo();" > /var/www/html/test.php
# 访问 http://yourdomain.com/test.php 测试
# 检查MySQL状态
systemctl status mysql
# 启动MySQL
systemctl start mysql
# 如果启动失败,查看日志
tail -50 /var/log/mysql/error.log
# 常见原因:
# 1. 内存不足导致OOM Kill(查看dmesg | grep -i oom)
# 2. 磁盘满导致无法启动
# 3. 表损坏:mysqlcheck --repair --all-databases
# 检查iptables是否阻止了80/443
iptables -L -n | grep -E "80|443"
# 检查ufw
ufw status
# 确保80和443端口放行
ufw allow 80/tcp
ufw allow 443/tcp
# 检查是否有安全组限制(KiwiVM面板)
# 检查证书是否过期
openssl s_client -connect yourdomain.com:443 -servername yourdomain.com 2>/dev/null | openssl x509 -noout -dates
# 如果证书过期,续期
certbot renew
# 强制续期
certbot renew --force-renewal
systemctl reload nginx
| 错误现象 | 可能原因 | 排查方向 |
|---|---|---|
| 连接超时 | IP被封/VPS关机/防火墙 | Ping测试、KiwiVM面板 |
| Connection refused | Nginx未运行/端口未监听 | systemctl status nginx |
| 空白页面 | PHP错误被隐藏 | 开启PHP错误显示 |
| 500 Internal Error | PHP错误/权限问题 | Nginx error.log |
| 502 Bad Gateway | PHP-FPM崩溃 | 参考502/504排查 |
| 503 Service Unavailable | 服务器过载/维护模式 | 检查资源使用率 |
| ERR_SSL_PROTOCOL_ERROR | SSL配置错误 | 检查证书和Nginx SSL配置 |
| ERR_NAME_NOT_RESOLVED | DNS解析失败 | 参考DNS排查 |
Tip: 建议配置网站监控(如UptimeRobot免费版),第一时间发现故障。更多教程请查看新手教程。