在 Debian 上安装 Apache(通常指 Apache HTTP Server)非常简单,以下是标准步骤(适用于 Debian 10/11/12 等主流版本):
sudo apt update
sudo apt install apache2
安装完成后,Apache 会自动:
sudo systemctl status apache2
如果看到 active (running) 表示运行正常。
常用命令:
sudo systemctl start apache2 # 启动
sudo systemctl stop apache2 # 停止
sudo systemctl restart apache2 # 重启
sudo systemctl reload apache2 # 重新加载配置
sudo ufw allow 'Apache Full'
查看规则:
sudo ufw status
在浏览器中访问:
http://服务器IP
或本地:
http://localhost
看到 Apache2 Debian Default Page 即表示成功。
/var/www/html
/etc/apache2/apache2.conf # 主配置
/etc/apache2/sites-available/ # 可用站点
/etc/apache2/sites-enabled/ # 已启用站点
/etc/apache2/mods-available/ # 可用模块
sudo a2ensite 000-default.conf # 启用站点
sudo a2dissite 000-default.conf # 禁用站点
sudo systemctl reload apache2
sudo a2enmod rewrite
sudo systemctl restart apache2
如果你需要:
可以告诉我你的具体使用场景,我可以一步步帮你配置。