以下是CentOS上排查LAMP故障的常用方法:
systemctl status httpd、systemctl status mysqld、systemctl status php-fpm(若使用PHP-FPM)查看服务是否运行,未运行则用 systemctl start 启动。/var/log/httpd/error_log/var/log/mysqld.log/var/log/php-fpm.log(或 php.ini 中配置的路径),用 tail -f 或 grep 过滤关键错误。apachectl configtest 检查配置文件语法错误。/etc/my.cnf 或 /etc/mysql/my.cnf 中的配置项(如端口号、数据目录权限)。netstat -tuln | grep -E '80|3306|9000' 查看端口是否被占用,冲突时调整配置或停止占用进程。iptables -L 或 firewall-cmd --list-ports。/var/www/html,权限设为755,所有者为 www 用户)。df -h 检查磁盘空间,确保有足够空间供服务运行。DocumentRoot 配置是否正确。my.cnf 中的 bind-address 配置。提示:修改配置后需重启对应服务(systemctl restart),若问题仍存在,可结合日志中的具体错误信息进一步分析。