Want to remove Nginx from Ubuntu?
Nginx is a web server that can also be used as a mail proxy, HTTP cache, reverse proxy, and load balancer. Nginx is quite a handy software and perhaps is the second most famous web server after Apache.
As it is well-known and widely used, you can expect Nginx to perform well. But as is the case with all software, it’s not perfect.
Although most of the errors can be resolved without much of a problem, there are times when you are unable to rectify the error even with prolonged troubleshooting. In cases like these, uninstalling the software feels like the best move possible.
For that or whatever reason, you’re here to know how to remove Nginx from your Ubuntu or other Linux distros. This article will guide you through the easy ways you can do just that.
So, let’s get started then!
Method 1: Uninstall Nginx Using Remove Command.
As you may know, most of the tasks performed in Linux systems are done through the Command Terminal. So, the first command you can use to remove Nginx from Ubuntu is the $ remove
command.
The $ remove
command is the go-to way of uninstalling any software. If you use the remove command, the Nginx configuration files will not be deleted, and they will be present in your system till you delete them as well.
The $ remove
command has a simple and very basic syntax and is used in combination with $ apt
:
$ sudo apt remove <software name>
So, in order to uninstall Nginx using $ remove
, follow these steps:
- Start by opening the Command Terminal by pressing Ctrl + Alt + T on your keyboard.
- Once opened, type the following command in the Terminal:
$ sudo apt remove nginx
The Terminal will ask for your password. Enter your password to start the process of installation.
- Before it gets rid of Nginx, it will ask for confirmation, as shown in the image. Press the Y and then Enter key to successfully remove Nginx.
With the steps followed correctly, you should now have uninstalled Nginx from your system. If this method doesn’t suit you, however, keep reading to check out the alternative method.
Method 2: Uninstalling Nginx Using the Purge Command.
The next command we will be discussing is the $ purge
command. $ purge
is another command that users of Linux distros use to get rid of unwanted software from their systems.
While $ remove
only removes the software package, $ purge
and deletes all the related files, folders, and directories related to the software as well.
The syntax for $ purge
is similar to $ remove
and it is also used in combination with $ apt
:
$ sudo apt purge <software name>
So, if you want to delete the software and its files as well, follow these steps:
- Start by opening the Command Terminal by pressing Ctrl + Alt + T on your keyboard.
- Once opened, type in the following command:
$ sudo apt purge nginx
- Finally, you need to enter your password to start the process.
That’s it. That’s another method you can use to remove Nginx from your Ubuntu and other Linux distros.
Reinstalling Nginx.
For the users who want just to get rid of errors but ultimately continue using Nginx, reinstalling it could be the appropriate action. Think somewhat works like you restart your computer when it becomes unresponsive. Although it isn’t a sure fix, it has little to no disadvantages, so it’s worth a shot.
For reinstalling Nginx on your Ubuntu or other Linux distros, you can use the $ reinstall command. It will first uninstall the package and then automatically install it again without getting rid of the configuration files. Similar to the previous commands, its syntax is simple and is used in combination with $ apt
:
$ sudo apt reinstall <software name>
So, to reinstall Nginx, follow these steps:
- Open the Terminal.
- Once opened, type in the following:
$ sudo apt reinstall nginx
- Lastly, enter the password to start the process.
You should see on your Terminal window that Nginx first gets uninstalled and then reinstalled. Now, check whether the service works or not.
While on the topic of uninstalling applications, knowing the difference between the $ remove
and $ purge
commands are crucial. Aside from that, there are other ways things could go wrong, and mitigation starts with getting the right information. For this reason, we recommend you learn how to properly install unwanted applications on Ubuntu.
We hope this guide helped you learn how to remove Nginx from your Ubuntu and other Linux distros. If you are having trouble uninstalling Nginx, or have suggestions to do it more efficiently, let us know in the comment section down below.