I'm switching from Apache2 to nginx. So I issued this command:

sudo apt-get purge apache2
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  389-ds-base 389-ds-base-libs ldap-utils libadminutil-data libadminutil0
  libapache2-mod-nss libds-admin-serv0 libmozilla-ldap-perl libnetaddr-ip-perl
  libnss3-tools libsocket-getaddrinfo-perl libsvrcore0
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
Suggested packages:
The following packages will be REMOVED:
  389-admin* apache2* libapache2-mod-php5*
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 3 to remove and 0 not upgraded.
Need to get 4277 kB of archives.
After this operation, 6360 kB of additional disk space will be used.
Do you want to continue? [Y/n]

Why is apt trying to install php-cgi? I'm trying to purge apache2, and will be purging php soon after, to install pph-fpm with nginx. I'm confused why an apt purge operation is attempting to install a package at all.

Debian 8, kernel 3.16.

  • I asked on #debian-apt, and Michael Vogt said to give the output of sudo apt install -o Debug::pkgProblemResolver=1 purge apache2. Can you run that and past the output into your question, please? Thanks. Feb 22, 2016 at 10:00
  • Also run with -o Debug::pkgDepCache::marker=1. Feb 23, 2016 at 9:33

1 Answer 1


Notice that libapache2-mod-php5 is being removed by your purge. This is because it's an Apache module/plugin and cannot be installed without Apache itself.

But you probably have some other package installed on your system that depends on PHP. This is not shown from the information you provided. That package (or those packages) would be left in the lurch if libapache2-mod-php5 were simply removed. Apt is solving the problem by installing pgp5-cgi instead. The package that depends on PHP is just as happy with php5-cgi as it was with libapache2-mod-php5 and your request to remove Apache now becomes possible to honour.

  • 1
    This analysis seems incomplete. "you probably have some other package installed on your system that depends on PHP". Well, Ok, but even assuming that is the case, why does PHP require libapache2-mod-php5 to be installed? Feb 21, 2016 at 15:12
  • Because libapache2-mod-php5 provides a PHP interpreter (that happens to run inside the web server). php5-cgi also provides a PHP interpreter. The unknown package probably doesn't care which PHP interpreter is installed, as long as there is one. Dependencies of the form libapache2-mod-php5 | php5-cgi | php5 are common.
    – Celada
    Feb 21, 2016 at 18:09
  • @Gilles I see. In that case I made an incorrect assumption and my answer is wrong.
    – Celada
    Feb 21, 2016 at 20:59
  • @Celada, I am undeleting this at the request of a couple of users in chat who pointed out that it is probably correct after all.
    – terdon
    Feb 22, 2016 at 8:48
  • Apologies for my earlier comment. In the distant past, apt never installed a package to honor a removal request, but its conflict resolution has become smarter since then. Feb 22, 2016 at 11:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .