在 Ubuntu 上启动 Apache(通常是 Apache2)一般有以下几个步骤,取决于你是否已经安装。
sudo apt update
sudo apt install apache2
安装完成后,Apache 通常会自动启动。
sudo systemctl start apache2
sudo systemctl enable apache2
sudo systemctl status apache2
如果看到 active (running),说明启动成功。
重启:
sudo systemctl restart apache2
停止:
sudo systemctl stop apache2
在浏览器访问:
http://localhost
或服务器 IP:
http://你的服务器IP
看到 Apache2 Ubuntu Default Page 即成功。
sudo systemctl stop nginx
或改 Apache 端口(/etc/apache2/ports.conf)
sudo ufw allow 80
如果你是用 Ubuntu 桌面版 / 服务器版 / WSL / 云服务器,可以告诉我具体环境,我可以给你更精确的命令。