温馨提示×

debian怎么卸载apache2

小樊
40
2026-10-15 05:32:42
栏目: 智能运维

在 Debian 系统下卸载 Apache2,可以按以下步骤操作:

1. 停止 Apache 服务

sudo systemctl stop apache2
sudo systemctl disable apache2

2. 卸载 Apache2 软件包

sudo apt remove apache2

3. 删除依赖和配置文件(彻底卸载)

sudo apt purge apache2
sudo apt autoremove

4. 手动清理残留文件(可选)

sudo rm -rf /etc/apache2
sudo rm -rf /var/www/html
sudo rm -rf /var/log/apache2

5. 确认已卸载

which apache2
apache2 -v

如果提示 command not found 说明已卸载干净。


说明:

  • remove:只删程序,保留配置
  • purge:连配置文件一起删
  • autoremove:清理不再需要的依赖

如果你是 Debian 12 / 11 / 10,以上命令都适用。需要我帮你写成一键脚本吗?

0 踩