在 CentOS 上查看 Apache 报错日志,通常按下面步骤来:
CentOS 上 Apache 一般是 httpd:
/var/log/httpd/
常用日志文件:
/var/log/httpd/error_log
/var/log/httpd/access_log
tail -f /var/log/httpd/error_log
或看最近 100 行:
tail -n 100 /var/log/httpd/error_log
比如找 Permission denied:
grep "Permission denied" /var/log/httpd/error_log
查看某个时间段的错误:
grep "2026" /var/log/httpd/error_log
systemctl status httpd
httpd -t
或
apachectl configtest
如果有错误,会直接告诉你哪一行配置有问题。
如果日志里有:
Permission denied
但权限明明是对的,很可能是 SELinux 问题。
查看 SELinux 报错:
grep httpd /var/log/audit/audit.log
临时关闭测试(不推荐长期关):
setenforce 0
systemctl status firewalld
开放 80/443:
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload
PHP 错误也可能写在 Apache 日志里,或者:
/var/log/php-fpm/error.log
(如果是 PHP-FPM)
如果你愿意,可以把 具体的报错内容贴出来,我可以直接帮你判断是权限、配置、SELinux 还是代码问题。