In this tutorial, we’ll be going over the step by step instructions to remove NGINX web server and reverse proxy server from Ubuntu Linux. Ubuntu offers us two options for uninstalling the software, either “remove” or “purge.” Read on to learn the difference and find out how to perform either function.
In this tutorial you will learn:
- How to remove NGINX from Ubuntu
- How to purge, or reinstall NGINX web server / reverse proxy from Ubuntu
|Requirements, Conventions or Software Version Used
|Privileged access to your Linux system as root or via the
|# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
Remove, Purge, or Reinstall NGINX
Ubuntu’s APT package manager gives us two different options for uninstalling packages from the system: remove and purge.
Remove will uninstall NGINX from the system, but leave the configuration files behind. In particular, this means that site configuration files in the
/etc/nginx directory are left alone. If you have any intention of reinstalling NGINX in the future, you should use the remove option instead of purge. Of course, the website files themselves, stored inside
/var/www will also not be deleted during the removal process.
Open a terminal and type the following command to remove NGINX.
$ sudo apt remove nginx
Purge will uninstall NGINX from the system, along with the configuration files inside
/etc/nginx. That directory will be deleted entirely. If the
/var/www is not empty, then the removal process leaves it intact, so you don’t need to worry about purge deleting your entire website. If you don’t plan to reinstall NGINX in the future, and don’t need your configuration files (or have already made a backup of them), then the purge option is for you. To err on the safe side, it’s advisable to backup your website files before doing a purge anyway.
Open a terminal and type the following command to purge NGINX.
$ sudo apt purge nginx
Reinstall will remove NGINX from your system and then install it again. It won’t make changes to your configuration files or
/var/www directory. Rather, NGINX system files are deleted and replaced. Your installation of NGINX would have to be pretty screwed up in order to justify this option, but it’s there in case you need it.
Open a terminal and type the following command to reinstall NGINX.
$ sudo apt reinstall nginx
In this tutorial, we saw a couple different options for removing NGINX from Ubuntu Linux. Ubuntu’s APT package manager makes uninstalling software very simple. The option to remove vs purge also protects users from accidentally deleting important files that they may want later (if, for example, they decide to reinstall NGINX).
Keep in mind that other web hosting components may still be installed on your system. For example, PHP and MySQL. Those are separate packages, maintained outside of NGINX, so you’ll need to remove them individually if you no longer want that software on your system.