温馨提示×

ubuntu apache如何开启

小樊
40
2026-10-19 18:29:45
栏目: 智能运维

在 Ubuntu 上开启(启动)Apache,通常步骤如下:

1. 安装 Apache(如果还没装)

sudo apt update
sudo apt install apache2

2. 启动 Apache

sudo systemctl start apache2

3. 设置开机自启(可选但推荐)

sudo systemctl enable apache2

4. 查看运行状态

sudo systemctl status apache2

看到 active (running) 就说明已经开启。

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

sudo ufw allow 'Apache'

或只开放 80 端口:

sudo ufw allow 80/tcp

6. 浏览器访问测试

在浏览器打开:

http://localhost

或服务器 IP:

http://你的服务器IP

看到 Apache 默认页面即成功。


常用命令汇总

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

如果你是 Ubuntu 14.04 及更早版本,用:

sudo service apache2 start

需要我帮你配置虚拟主机或 HTTPS 也可以继续问。

0 踩