温馨提示×

ubuntu apache如何启用

小樊
47
2026-09-26 09:08:18
栏目: 智能运维

在 Ubuntu 上启用 Apache(通常指 Apache2)一般步骤如下:


一、安装 Apache(如未安装)

sudo apt update
sudo apt install apache2

二、启动 Apache 服务

sudo systemctl start apache2

三、设置开机自启(启用)

sudo systemctl enable apache2

四、检查运行状态

sudo systemctl status apache2

看到 active (running) 说明已启用并运行。


五、防火墙放行(如有 UFW)

sudo ufw allow 80
# 如需 HTTPS
sudo ufw allow 443

然后浏览器访问:

http://服务器IP

看到 Apache2 Ubuntu Default Page 即成功。


六、常用管理命令

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

如果你是指 启用某个站点 / 模块(如 rewrite、ssl),也可以告诉我具体需求。

0 踩