How to Remove Nginx from Ubuntu

install mariadb on ubuntu

This brief tutorial shows students and new users how remove Nginx and/or purge from Ubuntu 20.04 | 18.04.

If you’re a webmaster and you want to remove Nginx web server from your host, the steps below will show you.

There are basically two ways to uninstall or remove programs from Ubuntu and Linux systems.

You can either run the apt remove or apt purge.

When you use the remove option with apt, the command will delete the software package from the system, but leave the configuration files behind.

Using purge with apt will delete the software package including all configurating files and settings.

When you want to delete Nginx from Ubuntu, follow the steps below:

Remove Nginx

Again, if you run apt with the remove option, it will delete Nginx from the host computer, but keep all configuration file intact.

If you thinking of removing Nginx to reinstall, then you may want to use the purge option.

If you simply want to remove Nginx package but key all configuration files, then run the commands below:

sudo apt remove nginx

The commands above delete Nginx but site configuration files in the /etc/nginx directory are left alone, including the content directory at /var/www.

Purge Nginx

The purge option with apt will delete Nginx and all configuration files from Ubuntu.

If you want to complete delete Nginx including configuration files and settings, then use the purge option.

The files in /etc/nginx directory will be removed. However, the site content at /var/www will be left alone.

Run the commands below to remove Nginx along with its configuration files.

sudo apt purge nginx

Reinstall Nginx

When you use the reinstall option with apt, the command will delete Nginx and install.

The reinstall option won’t change or delete any configuration file or the site content at /var/www.

It will simply delete and reinstall the Nginx packages.

To reinstall Nginx, run the commands below:

sudo apt reinstall nginx

That should do it!


This post showed you how to delete, purge or reinstall Nginx. If you find any error above, please use the comment form below to report.

You may also like the post below:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.