但是,我无法php再卸载:

但是,我无法php再卸载:

我已经php使用以下命令从我的 ubuntu 16.04 中清除:

sudo apt purge php

据我所记得,我收到了成功消息。但显然,php它仍然留在我的系统中。以下是证据:

1) $ php -v

输出:

PHP 7.0.28-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.28-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies

2)apt-cache policy php

输出:

php:
  Installed: (none)
  Candidate: 1:7.0+35ubuntu6
  Version table:
     1:7.0+35ubuntu6 500
        500 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages
        500 http://archive.ubuntu.com/ubuntu xenial/main i386 Packages

3)dpkg -l | grep -E '^ii' | grep php

输出:

ii  libapache2-mod-php7.0                         7.0.28-0ubuntu0.16.04.1                      amd64        server-side, HTML-embedded scripting language (Apache 2 module)
ii  php-cli-prompt                                1.0.1+dfsg-1build1                           all          tiny helper prompting for user input
ii  php-common                                    1:35ubuntu6.1                                all          Common files for PHP packages
ii  php-composer-semver                           1.2.0-1build1                                all          Semver library that offers utilities, version constraint parsing and
ii  php-composer-spdx-licenses                    1.1.2-1build1                                all          SPDX licenses list and validation library
ii  php-gd                                        1:7.0+35ubuntu6                              all          GD module for PHP [default]
ii  php-json-schema                               1.6.1-1build1                                all          implementation of JSON schema
ii  php-mysql                                     1:7.0+35ubuntu6.1                            all          MySQL module for PHP [default]
ii  php-symfony-console                           2.7.10-0ubuntu2                              all          run tasks from the command line
ii  php-symfony-filesystem                        2.7.10-0ubuntu2                              all          basic filesystem utilities
ii  php-symfony-finder                            2.7.10-0ubuntu2                              all          find files and directories
ii  php-symfony-process                           2.7.10-0ubuntu2                              all          execute commands in sub-processes
ii  php7.0-cli                                    7.0.28-0ubuntu0.16.04.1                      amd64        command-line interpreter for the PHP scripting language
ii  php7.0-common                                 7.0.28-0ubuntu0.16.04.1                      amd64        documentation, examples and common module for PHP
ii  php7.0-curl                                   7.0.28-0ubuntu0.16.04.1                      amd64        CURL module for PHP
ii  php7.0-gd                                     7.0.28-0ubuntu0.16.04.1                      amd64        GD module for PHP
ii  php7.0-json                                   7.0.28-0ubuntu0.16.04.1                      amd64        JSON module for PHP
ii  php7.0-mysql                                  7.0.28-0ubuntu0.16.04.1                      amd64        MySQL module for PHP
ii  php7.0-opcache                                7.0.28-0ubuntu0.16.04.1                      amd64        Zend OpCache module for PHP
ii  php7.0-readline                               7.0.28-0ubuntu0.16.04.1                      amd64        readline module for PHP
ii  php7.0-xml                                    7.0.28-0ubuntu0.16.04.1                      amd64        DOM, SimpleXML, WDDX, XML, and XSL module for PHP

4)$ which php$ which php7.0

输出:

/usr/bin/php或者/usr/bin/php7.0

但是,我无法php再卸载:

$ sudo apt remove php
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package 'php' is not installed, so not removed

答案1

根据apt描述php

该包为依赖包,依赖于Ubuntu默认的PHP版本(目前为7.2)。

因此,您已卸载php,以确保安装了最新的 Ubuntu php,但没有卸载单个 php 包本身。

现在要执行此操作,您必须使用 'php*': 清除 ,sudo apt purge php-*应该sudo apt purge php7.0*可以解决问题。使用libapache2-mod-php7.0手动清除sudo apt purge libapache2-mod-php7.0。如果您只是尝试删除 ,这可以避免与包管理发生冲突php*

此后,php 将被完全删除。要重新安装,只需使用 php,因为它具有所有依赖项。

相关内容