网站修改后无法启动?如何检查服务状态与日志信息?
1. 服务状态检查命令
服务类型 | 检查命令 | 重启命令 |
---|---|---|
Nginx/Apache | systemctl status nginx |
systemctl restart nginx |
MySQL | systemctl status mysql |
systemctl restart mysql |
PHP-FPM | systemctl status php-fpm |
systemctl restart php-fpm |
2. 关键日志文件定位
问题类型 | 日志路径 | 分析重点 |
---|---|---|
PHP错误 | /var/log/php_errors.log |
Fatal Error、Warning |
Web服务器错误 | /var/log/nginx/error.log |
502 Bad Gateway、404 |
数据库错误 | /var/log/mysql/error.log |
Can't connect、Deadlock |
系统级错误 | journalctl -xe |
服务启动失败详情 |
3. 快速恢复流程
- 回滚修改:
bash
# 使用Git回退(如果有版本控制) git checkout -- .
- 验证配置:
bash
# Nginx配置测试 nginx -t
- 增量排查:
- 先重启服务,观察能否临时恢复
- 对比修改前后的文件差异(如
diff file_old file_new
)
log
# PHP日志示例 [Wed Jul 10 10:00:00] PHP Fatal error: Uncaught Error: Class 'Redis' not found in /app/Cache.php:30
apt install php-redis
更新时间:2025-06-21 23:19:36
上一篇:数据导入提示“Duplicate entry”主键冲突?应如何处理已有数据?
下一篇:网站首页文件被改如何查看日志?