Ubuntu – Apt-get — remove triggers a package install

aptdpkgpurgeuninstall

I want to remove and purge apache2 – Why does this trigger an install of php5-cgi ?

sudo apt-get --purge remove apache2

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-headers-3.19.0-20 linux-headers-3.19.0-20-generic linux-image-3.19.0-20-generic linux-image-extra-3.19.0-20-generic linux-signed-image-3.19.0-20-generic linux-tools-3.19.0-20
  linux-tools-3.19.0-20-generic
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  php5-cgi
Suggested packages:
  php-pear
The following packages will be REMOVED:
  apache2* libapache2-mod-php5*
The following NEW packages will be installed:
  php5-cgi
0 upgraded, 1 newly installed, 2 to remove and 15 not upgraded.
Need to get 4,419 kB of archives.
After this operation, 8,152 kB of additional disk space will be used.
Do you want to continue? [Y/n] n
Abort.

When I issued above it did infact install that new package !!! I would not think its an alternative

Best Answer

The package php5 depends on having either apache2 or cgi installed.

The two main options to satisfy this dependency is either libapache2-mod-php5 or php5-cgi.

If you remove one, the system will install the other, otherwise php5 would have an unmet dependency.

You can see the dependencies at php5 in the Ubuntu packages database.