温馨提示×

如何Ubuntu开Apache2

小樊
41
2026-10-11 03:11:35
栏目: 智能运维

在 Ubuntu 上开启(启动)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. 验证是否成功

在浏览器访问:

http://localhost

或服务器 IP,看到 Apache 默认页面即成功。


常见补充命令

  • 停止 Apache:
    sudo systemctl stop apache2
    
  • 重启 Apache:
    sudo systemctl restart apache2
    
  • 重新加载配置(不中断服务):
    sudo systemctl reload apache2
    

如果你是要开启某个站点/虚拟主机或配置防火墙(ufw),也可以告诉我具体需求。

0 踩