温馨提示×

如何在debian装apache2

小樊
44
2026-09-30 14:41:34
栏目: 智能运维

在 Debian 上安装 Apache2 非常简单,一般步骤如下:

1. 更新软件包索引

sudo apt update

2. 安装 Apache2

sudo apt install apache2 -y

3. 启动并设置开机自启

sudo systemctl start apache2
sudo systemctl enable apache2

4. 检查运行状态

sudo systemctl status apache2

看到 active (running) 就说明成功了。

5. 防火墙放行(如有启用 ufw)

sudo ufw allow 'Apache'
# 或
sudo ufw allow 80/tcp

6. 验证

浏览器访问服务器 IP:

http://你的服务器IP/

看到 Apache2 Debian Default Page 即安装成功。


常用管理命令

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

网站目录

  • 默认网页目录:/var/www/html
  • 配置文件:/etc/apache2/

如果你需要 配置虚拟主机 / HTTPS / PHP,也可以继续问我。

0 踩