12

I have been experimenting with nginx as a webserver for php files. I come from an Apache background but I wanted to try it. I recently had an issue with it and needed to switch back to Apache. I removed it using apt-get remove nginx.

This worked fine and I installed Apache and life was good. I restarted my computer and somehow nginx started up. I didn't understand. I tried to remove it again and I got the message:

$ sudo apt-get remove nginx
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'nginx' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.

If I look for the program (screenshot):

$ which nginx
/usr/sbin/nginx

Does anyone know if I am doing something wrong or what the next step to removing it would be?

I am using Xubuntu 14.04.

David Foerster
  • 36,264
  • 56
  • 94
  • 147
arty
  • 123

2 Answers2

24

nginx is a metapackage, so you need to remove whatever was installed by this package. If doing sudo apt-get autoremove doesn't do the trick, you can run sudo apt-get remove nginx-core nginx-full nginx-light nginx-extras nginx-naxsi nginx-common (you probably have only one of these packages installed, but the command shouldn't fail).

saiarcot895
  • 10,757
  • 2
  • 36
  • 39
  • Thank you! Any idea how I can determine which packages are meta packages? – arty Apr 29 '14 at 13:09
  • 1
    I typically go by the size of the package. If the Installed-Size of the package (apt-cache show nginx, or apt-cache show ubuntu-desktop) is less than 100, then there's a good chance that it's just a metapackage, and to look at the dependencies (which may point to a specific version or variant of the software). Also, packages that are in the metapackages section are certain to be metapackages; however, not all metapackages are in the metapackages section. – saiarcot895 Apr 29 '14 at 13:13
  • The most possible ones would be nginx-core & nginx-common. Thank you. – m3nda May 28 '15 at 23:17
3

sudo apt-get remove --purge nginx* will remove whatever is installed and is related to nginx, including configuration files. It will also list packages available in repositories which match the regex nginx* and are not installed.

There is a difference between apt-get remove and apt-get purge. The --purge option removes also the configuration files. It is useful for a clean reinstall.

Typing the command:

sudo apt-get remove --purge nginx*

will result in:

The following packages will be REMOVED:
nginx-common*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? 
(Reading database ... 55416 files and directories currently installed.)
Removing nginx-common ...
Purging configuration files for nginx-common ...
ftcosta
  • 31