Debian 上 Apache 无法启动的原因有很多,下面按最常见 → 较少见的顺序帮你排查。你可以一条条对照。
先执行:
sudo systemctl status apache2
sudo journalctl -xe
或者:
sudo apache2ctl configtest
通常会直接告诉你问题在哪。
sudo netstat -tulnp | grep ':80'
或
sudo ss -tulnp | grep ':80'
常见冲突:
解决:
/etc/apache2/ports.confsudo apache2ctl configtest
常见错误:
DocumentRoot 不存在</VirtualHost>Apache 默认用户是 www-data
检查:
ls -ld /var/www/html
修复:
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 755 /var/www/html
例如同时启用 mpm_prefork 和 mpm_event
查看:
sudo a2query -m
解决:
sudo a2dismod mpm_event
sudo a2enmod mpm_prefork
如果你启用了 ssl:
sudo apache2ctl configtest
常见:
dpkg -l | grep apache2
重装:
sudo apt reinstall apache2
systemctl is-enabled apache2
如果是 masked:
sudo systemctl unmask apache2
df -h
free -m
apache2ctl configtest 无错误/var/www 权限正确systemctl status apache2 正常如果你愿意,可以把下面两条命令的输出贴出来,我可以直接帮你定位:
sudo systemctl status apache2
sudo apache2ctl configtest