在 Ubuntu 上启动 Apache(通常指 Apache HTTP Server,即 apache2),可以按下面步骤操作:
sudo apt update
sudo apt install apache2
sudo systemctl start apache2
sudo systemctl enable apache2
sudo systemctl status apache2
如果看到 active (running) 说明启动成功。
在浏览器中访问:
http://localhost
或服务器 IP 地址,看到 Apache2 Ubuntu Default Page 即表示成功。
# 停止
sudo systemctl stop apache2
# 重启
sudo systemctl restart apache2
# 重新加载配置(不中断服务)
sudo systemctl reload apache2
# 禁用开机启动
sudo systemctl disable apache2
sudo netstat -tulnp | grep :80
或
sudo ss -tulnp | grep :80
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw reload
sudo apache2ctl configtest
如果你用的是 Ubuntu 版本(如 20.04 / 22.04) 或 想配置虚拟主机、HTTPS,可以继续问我。