Removing Nginx completely from Ubuntu

Tonight I tried to make a clean installation of Nginx in my Virtual Private Server, which is running Ubuntu 12.04, so I ran:

sudo apt-get purge nginx

To my surprise, after running this command the folder /etc/nginx still existed with all its content intact. This was weird because purge (as opposed to remove) should remove configuration files.

Because I am stickler, I decided I wanted to find a way to uninstall nginx with just one command, so I reinstalled it all over and tried again. This time I dug a little around and I found 3 packages that seemed relevant: nginx, nginx-full, and nginx-common. I tried luck with each one of them and this is the one that did it:

sudo apt-get purge nginx-common

Weird right? I would have put my money on nginx-full, but no, this was the one that did it. Now your system is nginx-free with no trace of it anywhere. Now you can reinstall it in a clean state.

Or just leave it uninstalled 🙂

Comments

Francisco Luz

Cheers bro, that’s what I was looking for.

Alain Alemany

Quick tip: After “sudo apt-get purge nginx” all Nginx dependencies will just sitting around. Use “sudo apt autoremove” and everything will be gone, including nginx-common.

emre

Hello,
I have read the nginx removal instructions that you wrote in 2014. I want to remove this server and try all the ways. It seems to have been removed on my system, but localhost also says welcome to nginx. I can not help it because of my bad english 🙂

Leave a Reply

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