在 CentOS 上查看 Apache 日志,通常步骤如下:
systemctl status httpd
(CentOS 中 Apache 服务名一般是 httpd)
如果未运行,可启动:
systemctl start httpd
CentOS 下 Apache 日志通常在:
/var/log/httpd/
常见日志文件:
/var/log/httpd/access_log/var/log/httpd/error_logtail -f /var/log/httpd/error_log
tail -f /var/log/httpd/access_log
tail -n 100 /var/log/httpd/error_log
grep "404" /var/log/httpd/access_log
grep "error" /var/log/httpd/error_log
grep -i "log" /etc/httpd/conf/httpd.conf
或虚拟主机配置:
grep -ri "log" /etc/httpd/conf.d/
可查看:
getsebool -a | grep httpd
有些错误也会记录在系统日志:
journalctl -u httpd
如果你用的是 CentOS 8+ / Stream 或 Apache + PHP / Nginx 反代,日志位置可能不同,可以告诉我你的具体环境,我可以给你更精确的命令。