Debian 上 LNMP(Linux + Nginx + MySQL/MariaDB + PHP)启动失败 的原因很多,需要按组件逐个排查。下面我按最常见原因 → 排查方法 → 解决办法给你一个系统性的排查清单。
分别在终端执行:
systemctl status nginx
systemctl status mariadb # 或 mysql
systemctl status php-fpm
看哪个是 failed / inactive。
nginx -t
如果看到:
nginx: [emerg] unknown directive
nginx: configuration file /etc/nginx/nginx.conf test failed
✅ 解决办法:
/etc/nginx/sites-enabled/ 里的配置fastcgi_pass 是否指向正确的 PHP-FPM socketss -lntp | grep :80
✅ 解决:
systemctl stop apache2
systemctl disable apache2
或改 Nginx 端口。
tail -n 50 /var/log/nginx/error.log
systemctl status mariadb
chown -R mysql:mysql /var/lib/mysql
df -h
mysqld --verbose --help | grep my.cnf
✅ 检查:
/etc/mysql/my.cnf
/etc/mysql/mariadb.conf.d/
tail -n 50 /var/log/mysql/error.log
systemctl status php8.2-fpm
(版本可能是 7.4 / 8.1 / 8.2)
Nginx 里:
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
检查:
ls /run/php/
✅ 如果不存在:
systemctl restart php8.2-fpm
tail -n 50 /var/log/php8.2-fpm.log
如果是 服务都启动了,但访问 502 / 404:
通常是:
✅ 解决:
chmod 755 /run/php
aa-status
临时测试:
systemctl stop apparmor
systemctl enable nginx mariadb php8.2-fpm
nginx -t
systemctl restart nginx mariadb php8.2-fpm
ss -lntp
df -h
请把以下信息贴出来(越全越好):
cat /etc/debian_version)systemctl status nginx mariadb php-fpmnginx -t 输出我可以直接帮你精准定位是哪一步出错 ✅