Uninstall Nginx Completely on Debian/Ubuntu-Based Linux
This guide will cover how to completely uninstall Nginx web server (including its dependencies, modules, configuration files and logs) on Debian/Ubuntu-based Linux distros (e.g. Linux Mint, Pop!_OS, Elementary OS). It's useful when you're trying to reinstall a clean Nginx server.
In case Nginx server is still running, let's stop the Nginx service (
sudo systemctl stop nginx Bash
In this step we'll uninstall Nginx and its related packages from our system.
Purge the main Nginx packages:
sudo apt purge nginx* Bash
Remove the unused dependencies with
sudo apt autoremove Bash
Although Nginx is now uninstalled, there are still some files generated by Nginx left to clean.
Configuration Files (Optional)
Remove the configuration files in
sudo rm -rf /etc/nginx Bash
Remove the logs in
sudo rm -rf /var/log/nginx Bash