Table of Contents

Uninstall Nginx Completely on Debian/Ubuntu-Based Linux

Cyrus Kao
Last modified on .

This guide will cover how to completely uninstall the 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.

Nginx (/usr/sbin/nginx) running in the background

Stop Service

In case the Nginx server is still running, let's stop the Nginx service (nginx.service) first:

$ sudo systemctl stop nginx


In this step, we'll uninstall Nginx and its related packages from our system.

Main Packages

Purge the main Nginx packages:

$ sudo apt purge nginx*


Remove the unused dependencies with autoremove:

$ sudo apt autoremove

Clean Up

Although Nginx is now uninstalled, there are still some files generated by Nginx left to clean.

Configuration Files (Optional)

Remove the configuration files in /etc/nginx:

$ sudo rm -rf /etc/nginx

Logs (Optional)

Remove the logs in /var/log/nginx

$ sudo rm -rf /var/log/nginx

See Also


Sign in to leave a comment.