In this guide, 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, purge, or reinstall NGINX web server / reverse proxy from Ubuntu
Uninstalling NGINX from Ubuntu
Uninstalling NGINX from Ubuntu
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Ubuntu Linux
Software NGINX
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ - 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.


SUBSCRIBE NEWSLETTER & RSS
Subscribe to RSS and NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


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

Closing Thoughts

In this guide, 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.

FIND LATEST LINUX JOBS on LinuxCareers.com
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.