在Debian上排查LNMP故障可按以下步骤进行:
tail -f /var/log/syslog 或 journalctl 查看系统级错误日志。systemctl status nginx、systemctl status mysql、systemctl status php7.x-fpm(版本需替换)。nginx -t 测试配置文件语法,检查 /etc/nginx/nginx.conf 及站点配置。/etc/mysql/my.cnf,确保数据目录权限正确(chown -R mysql:mysql /var/lib/mysql)。/etc/php/7.x/fpm/php-fpm.conf 及 pool.d/www.conf,确认监听端口/套接字、用户权限正确。netstat -tuln 或 ss -tuln 确认服务监听端口(Nginx:80/443,MySQL:3306,PHP-FPM:9000),确保未被占用。ufw 或 iptables),放行必要端口。www-data)对网站目录、配置文件有读写权限:chown -R www-data:www-data /var/www/html。/var/log/nginx/error.log,重点关注404、502等错误。/var/log/mysql/error.log,排查启动失败、权限或数据损坏问题。/var/log/php7.x-fpm.log,处理进程崩溃或扩展加载失败。top、free -h 查看系统资源(CPU、内存、磁盘)是否充足。sudo apt-get install -f。systemctl restart nginx mysql php7.x-fpm。关键命令总结:
systemctl status <服务名>、systemctl restart <服务名>tail -f /var/log/<服务名>/error.lognginx -t、php-fpm7.x -tnetstat -tuln | grep <端口号>按步骤逐步排查,可快速定位并解决LNMP环境中的常见故障。