在 CentOS 上,Apache 通常叫 httpd(而不是 apache2,apache2 是 Debian/Ubuntu 的叫法)。
默认日志路径一般在:
/var/log/httpd/
常见日志文件:
/var/log/httpd/access_log/var/log/httpd/error_log# 查看错误日志
tail -f /var/log/httpd/error_log
# 查看访问日志
tail -f /var/log/httpd/access_log
# 查看最后 100 行
tail -n 100 /var/log/httpd/error_log
# 实时查看并过滤错误
tail -f /var/log/httpd/error_log | grep error
systemctl status httpd
如果未安装:
yum install httpd -y
查看实际日志路径(防止自定义配置):
httpd -S
# 或
grep -R "ErrorLog" /etc/httpd/
grep -R "CustomLog" /etc/httpd/
可能在:
/usr/local/apache/logs/
或配置文件中指定的路径。
如果你能告诉我 CentOS 版本 或 Apache 安装方式(yum / 源码),我可以给你更精确的命令。