温馨提示×

怎么在Ubuntu开Apache2

小樊
39
2026-10-08 03:12:22
栏目: 智能运维

在 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:

http://你的服务器IP

看到 Apache2 Ubuntu Default Page 就说明正常。


常用命令补充

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

如果你是要配置虚拟主机、开启 HTTPS、或防火墙放行 80/443 端口,也可以继续问我。

0 踩