在 Ubuntu 上启动 Apache2(通常叫 apache2 或 httpd,Ubuntu 里是 apache2)常用以下几种方式:
sudo systemctl start apache2
设置开机自启:
sudo systemctl enable apache2
查看状态:
sudo systemctl status apache2
sudo service apache2 start
sudo systemctl stop apache2 # 停止
sudo systemctl restart apache2 # 重启
sudo systemctl reload apache2 # 重新加载配置(不中断服务)
浏览器访问:
http://localhost
或命令行:
curl http://localhost
如果看到 Apache 默认页面,说明启动成功。
如果提示没安装:
sudo apt update
sudo apt install apache2
如果端口被占用(如 80 端口):
sudo netstat -tulnp | grep :80
检查是否有 nginx 或其他程序占用。
需要我帮你排查启动失败的具体报错也可以贴出来。