在 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
或
http://服务器IP
看到 Apache2 Ubuntu Default Page 即表示成功。
# 停止
sudo systemctl stop apache2
# 重启
sudo systemctl restart apache2
# 重新加载配置(不中断服务)
sudo systemctl reload apache2
如果无法访问,可能需要放行 80 端口:
sudo ufw allow 'Apache'
或:
sudo ufw allow 80/tcp
sudo netstat -tulnp | grep :80
或
sudo ss -tulnp | grep :80
sudo tail -f /var/log/apache2/error.log
如果你是在 Ubuntu 22.04 / 24.04、服务器环境、或 Docker / WSL 中运行,可以告诉我,我可以给你更具体的指导。