NGINX is a popular choice for web servers, but if you’d like to remove the software, we’ve got you covered here. In this guide, we’ll show how to properly uninstall and remove NGINX from Ubuntu Linux.
The best way to remove NGINX from Ubuntu is by using the built-in APT package manager. APT gives us two different options for uninstalling software: remove and purge.
If you remove NGINX from Ubuntu, APT leaves behind the package’s configuration files. Namely these would be the files inside the /etc/nginx
directory, where the settings for your website(s) are stored.
If you decide to purge NGINX, the pertinent configuration files will be deleted along with the rest of the program.
Use one of the following options to remove NGINX from Ubuntu. Note the --auto-remove
option also gets rid of related packages in nginx-common
that are no longer needed.
Option 1. Remove NGINX from the system, while preserving configuration files.
$ sudo apt remove --auto-remove nginx
Option 2. Purge NGINX from the system, which also deletes configuration files.
$ sudo apt remove --auto-remove nginx
Option 3. Reinstall NGINX, which won’t overwrite configuration files, but gives you a fresh copy of the software.
$ sudo apt reinstall nginx
You can verify that NGINX is uninstalled by typing the following command, which lists installed packages that contain “nginx” in their name.
$ apt list --installed | grep nginx
Although NGINX is removed, you may still have other web hosting packages lingering on your system, such as PHP or MySQL. These will need to be removed separately if you no longer want them.