在CentOS排查Apache配置错误可按以下步骤进行:
/var/log/httpd/error_log
。sudo tail -f /var/log/httpd/error_log
。sudo apachectl configtest
或 sudo httpd -t
。sudo netstat -tulnp | grep ':80\|:443'
。apache
)对配置文件、网站目录有访问权限:sudo chown -R apache:apache /var/www/html
sudo chmod -R 755 /var/www/html
。sestatus
。Enforcing
模式,可临时设为Permissive
排查问题:sudo setenforce 0
,完成后恢复sudo setenforce 1
。sudo systemctl restart httpd
。sudo systemctl status httpd
,确保为active (running)
。关键命令总结:
sudo tail -f /var/log/httpd/error_log
。sudo apachectl configtest
。sudo netstat -tulnp | grep ':80'
。sudo chown -R apache:apache /var/www/html
。