温馨提示×

debian apache2如何启用

小樊
42
2026-10-09 09:54:12
栏目: 智能运维

在 Debian 系统上启用 Apache2(安装并启动、设置开机自启)通常步骤如下:


1. 安装 Apache2

sudo apt update
sudo apt install apache2

2. 启动 Apache2

sudo systemctl start apache2

3. 设置开机自动启动

sudo systemctl enable apache2

4. 查看运行状态

sudo systemctl status apache2

看到 active (running) 表示已成功启用。


5. 防火墙放行(如有 UFW)

sudo ufw allow 80
sudo ufw allow 443

6. 测试访问

浏览器访问:

http://服务器IP

看到 Apache2 Debian Default Page 即正常。


常用管理命令

sudo systemctl stop apache2     # 停止
sudo systemctl restart apache2  # 重启
sudo systemctl reload apache2   # 重新加载配置

如果你是说启用某个站点 / 模块 / 重写规则,也可以告诉我具体需求。

0 踩