下面按**最常见的 Debian 系列(Debian 10/11/12)**说明如何启用 Apache(即安装并启动、设置开机自启)。
sudo apt update
sudo apt install apache2 -y
sudo systemctl start apache2
检查运行状态:
sudo systemctl status apache2
看到 active (running) 即表示已启用成功。
sudo systemctl enable apache2
如果系统使用 ufw:
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
(HTTPS 可选,若后续启用 SSL)
浏览器访问:
http://服务器IP
或本机测试:
curl http://localhost
看到 Apache2 Debian Default Page 即正常。
sudo systemctl stop apache2 # 停止
sudo systemctl restart apache2 # 重启
sudo systemctl reload apache2 # 重新加载配置
启用模块(如 rewrite):
sudo a2enmod rewrite
sudo systemctl restart apache2
启用站点:
sudo a2ensite 你的站点配置
sudo systemctl reload apache2
如果你是指:
可以告诉我具体场景,我可以进一步帮你排查。