在 Ubuntu 上安装 Apache 非常简单,对新手也很友好,一般 1~2 分钟就能完成。下面给你一个最常用、最稳妥的做法。
sudo apt update
sudo apt install apache2
sudo systemctl start apache2
sudo systemctl enable apache2
在浏览器中访问:
http://你的服务器IP
如果看到 Apache2 Ubuntu Default Page,说明安装成功 ✅
sudo systemctl status apache2 # 查看状态
sudo systemctl stop apache2 # 停止
sudo systemctl start apache2 # 启动
sudo systemctl restart apache2 # 重启
/var/www/html
/etc/apache2/
/etc/apache2/sites-available/
/etc/apache2/sites-enabled/
✅ 检查:
sudo ufw allow 80
sudo apt install php libapache2-mod-php
sudo systemctl restart apache2
✅ Ubuntu 装 Apache 一点也不难
✅ 几条命令就能跑起来
✅ 非常适合新手学习 Web 服务
如果你愿意,我可以继续教你:
你现在是用 本地虚拟机、云服务器,还是 WSL?