在 Ubuntu 上卸载 Apache2,可以按下面步骤操作,根据你是否需要彻底清除来选择。
sudo systemctl stop apache2
sudo apt remove apache2
sudo apt purge apache2
sudo apt autoremove
清理可能残留的目录:
sudo rm -rf /etc/apache2
sudo rm -rf /var/www/html
sudo rm -rf /var/log/apache2
which apache2
systemctl status apache2
如果显示 command not found 或 Unit apache2.service could not be found,说明已卸载成功。
有时 Apache 是通过 LAMP 套件安装的,可额外检查:
sudo apt purge apache2 apache2-utils apache2-bin apache2.2-common
如果你之后打算 重装 / 换 Nginx / 用 Docker,也可以告诉我,我可以给你对应方案。