在 Ubuntu 上启动 Apache2(通常叫 apache2 或 httpd 的服务名是 apache2)常见方法如下:
sudo systemctl start apache2
设置开机自启:
sudo systemctl enable apache2
查看状态:
sudo systemctl status apache2
sudo service apache2 start
sudo systemctl restart apache2 # 重启
sudo systemctl stop apache2 # 停止
浏览器访问:
http://localhost
或命令行:
curl http://localhost
如果看到 Apache 默认页面,说明启动成功。
sudo netstat -tulnp | grep :80
sudo apt update
sudo apt install apache2
如果你是在 容器 / WSL / 特殊环境 里用,也可以告诉我,我可以给你对应方案。