简体   繁体   中英

Why does uninstalling Apache2 try to install PHP5-CGI?

As you can see from the screenshot below (I highlighted the relevant parts) when I try to uninstall Apache from my Ubuntu server it wants to install PHP5-CGI. Why does this happen? Do I need to use a different command to uninstall it?

控制台截图

My guess is it's because another package has php as a dependency.

But libapache2-mod-php5 satisfied that dependency, but when you remove apache, libapache2-mod-php5 has apache as a dependency, so it can't stay installed. Thus, apt goes for the next in line that satisfies the dependency for php, which appears to be php5-cgi

However, you can find this out for sure by running:

apt-cache rdepends --installed php5-cgi

and also run now:

apt-cache rdepends --installed libapache2-mod-php5

This should show you right now what is depending on that package.

It's probably wordpress or something like that would be my guess.

apt-cache show wordpress
Depends: apache2 | httpd, libapache2-mod-php5 | php5, ca-certificates, mysql-client | mariadb-client, php5-gd, php5-mysql | php5-mysqlnd, libjs-cropper (>= 1.2.2), libjs-mediaelement (>= 2.15.1+dfsg), libphp-phpmailer (>= 5.2.10+dfsg), php-getid3 (>= 1.9.9+dfsg)

Then I assume php5 itself, the second option, is a metapackage, so I check it's dependencies:

apt-cache show php5
Depends: libapache2-mod-php5 (>= 5.6.14+dfsg-1~) | libapache2-mod-php5filter (>= 5.6.14+dfsg-1~) | php5-cgi (>= 5.6.14+dfsg-1~) | php5-fpm (>= 5.6.14+dfsg-1~), php5-common (>= 5.6.14+dfsg-1~)
## or if you prefer
apt-cache depends php5
php5
 |Depends: libapache2-mod-php5
 |Depends: libapache2-mod-php5filter
 |Depends: php5-cgi
  Depends: php5-fpm

I find apt-cache show output is easier to read though, because it's easier to see what is a set of options per dependency.

As you can see, if we take the example of wordpress, it has the dependency of libapache2-mod-php5 OR php5, and php5 in turn has the dependency of libapache2-mod-php5 OR libapache2-mod-php5filter OR php5-cgi OR php5-fpm, so it looks like all apt is doing is going down the list, and since you are removing the first dependency, it goes to php5, checks that, and again, you are removing the first option, the second, libapache2-mod-php5filter, also has apache as a dependency, but you are removing apache2 in this operation, so it goes to php5-cgi, which does not depend on apache, and there you have it.

Or something like that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM