Debian 上 LAMP(Linux + Apache + MySQL/MariaDB + PHP)启动失败 通常不是单一原因,而是 Apache / MariaDB / PHP 配置或依赖 出了问题。下面按最常见原因 → 排查方法 → 解决办法给你一个系统性的排查清单。
systemctl status apache2
常见状态:
failedinactive (dead)active (running)systemctl status mariadb
# 或
systemctl status mysql
php -v
apache2ctl -M | grep php
ss -lntp | grep :80
如果看到 nginx / 其他程序:
systemctl stop nginx
或修改 Apache 端口:
/etc/apache2/ports.conf
apache2ctl configtest
常见错误:
Syntax errorInvalid commandSSLCertificateFile not found✅ 修复后:
systemctl restart apache2
ls /etc/apache2/sites-enabled/
临时排查:
a2dissite 000-default.conf
systemctl restart apache2
apache2ctl -M
禁用可疑模块:
a2dismod mpm_event
a2enmod mpm_prefork
ls -ld /var/lib/mysql
修复:
chown -R mysql:mysql /var/lib/mysql
df -h
mysqld --verbose --help | grep my.cnf
检查:
/etc/mysql/my.cnf
/etc/mysql/mariadb.conf.d/
journalctl -xe
cat /var/log/mysql/error.log
apt install libapache2-mod-php
启用:
a2enmod php8.x
systemctl restart apache2
Debian 12 常见问题:
mpm_eventmpm_preforka2dismod mpm_event
a2enmod mpm_prefork
a2enmod php8.x
ufw status
ufw allow 80/tcp
getenforce
systemctl status apache2
systemctl status mariadb
apache2ctl configtest
journalctl -xe
如果你愿意,把下面信息贴出来,我可以直接帮你定位:
systemctl status apache2
systemctl status mariadb
apache2ctl configtest
cat /var/log/apache2/error.log | tail -20
或者告诉我:
我可以一步一步带你修好 ✅