在 Ubuntu 上启动 Apache(通常是 Apache2)可以按下面步骤来:
sudo apt update
sudo apt install apache2
sudo systemctl start apache2
sudo systemctl enable apache2
sudo systemctl status apache2
看到 active (running) 就说明启动成功了。
sudo systemctl stop apache2 # 停止
sudo systemctl restart apache2 # 重启
sudo systemctl reload apache2 # 重新加载配置(不中断服务)
在浏览器中访问:
http://localhost
或服务器 IP 地址,看到 Apache2 Ubuntu Default Page 就说明 OK 了。
sudo netstat -tulnp | grep :80
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
如果你是在 云服务器、Docker、WSL 或遇到具体报错,可以告诉我,我可以针对你的环境详细说明。