在 Debian 系统上卸载 Nginx,通常可以按以下步骤操作(根据你的安装方式不同,命令略有区别)。
apt 安装的 Nginx(最常见)sudo systemctl stop nginx
sudo systemctl disable nginx
sudo apt remove nginx nginx-common nginx-full nginx-light nginx-core
如果不确定装了哪些包,可以先查看:
dpkg -l | grep nginx
sudo apt purge nginx nginx-common
sudo apt autoremove
sudo rm -rf /etc/nginx
sudo rm -rf /var/log/nginx
sudo rm -rf /var/www/html # 如果你没用这个目录可删
源码安装没有包管理器记录,需要手动删除:
sudo nginx -s stop
或
sudo pkill nginx
sudo rm -rf /usr/local/nginx
sudo rm -f /usr/local/sbin/nginx
sudo rm -f /etc/systemd/system/nginx.service
sudo systemctl daemon-reload
which nginx
nginx -v
如果都提示 command not found,说明已成功卸载。
如果你愿意,可以告诉我:
我可以给你更精确的命令。