在 WSL2 中的 Ubuntu-20.04 中卸载 PHP 7.4,然后安装 PHP 8
wangqiang@DESKTOP-QLPK8QM:~$ sudo apt install php Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: libfwupdplugin1 libxmlb1 Use 'sudo apt autoremove' to remove them. The following additional packages will be installed: apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php7.4 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libjansson4 liblua5.2-0 php-common php7.4 php7.4-cli php7.4-common php7.4-json php7.4-opcache php7.4-readline ssl-cert Suggested packages: apache2-doc apache2-suexec-pristine | apache2-suexec-custom php-pear openssl-blacklist The following NEW packages will be installed: apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php7.4 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 Enabling module status. Enabling module reqtimeout. Enabling conf charset. Enabling conf localized-error-pages. Enabling conf other-vhosts-access-log. Enabling conf security. Enabling conf serve-cgi-bin. Enabling site 000-default. info: Switch to mpm prefork for package libapache2-mod-php7.4 Module mpm_event disabled. Enabling module mpm_prefork. info: Executing deferred 'a2enmod php7.4' for package libapache2-mod-php7.4 Enabling module php7.4. Created symlink /etc/systemd/system/multi-user.target.wants/apache2.service → /lib/systemd/system/apache2.service. Created symlink /etc/systemd/system/multi-user.target.wants/apache-htcacheclean.service → /lib/systemd/system/apache-htcacheclean.service. invoke-rc.d: could not determine current runlevel Setting up php7.4 (7.4.3-4ubuntu2.18) ... Setting up php (2:7.4+75) ... Processing triggers for ufw (0.36-6ubuntu1) ... Processing triggers for systemd (245.4-4ubuntu3.21) ... Processing triggers for man-db (2.9.1-1) ... Processing triggers for libc-bin (2.31-0ubuntu9.9) ... /sbin/ldconfig.real: /usr/lib/wsl/lib/libcuda.so.1 is not a symbolic link Processing triggers for php7.4-cli (7.4.3-4ubuntu2.18) ... Processing triggers for libapache2-mod-php7.4 (7.4.3-4ubuntu2.18) ...
2、先卸载掉 PHP 7.4 及其依赖
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ sudo apt-get purge php7.* Reading package lists... Done Building dependency tree Reading state information... Done Note, selecting 'php7.4-ds' for glob 'php7.*' Note, selecting 'php7.4-bz2' for glob 'php7.*' Note, selecting 'php7.4-gd' for glob 'php7.*' Note, selecting 'php7.4-ps' for glob 'php7.*' Note, selecting 'php7.4-cgi' for glob 'php7.*' Note, selecting 'php7.4-cli' for glob 'php7.*' Note, selecting 'php7.4-uuid' for glob 'php7.*' Note, selecting 'php7.4-pdo-odbc' for glob 'php7.*' Note, selecting 'php7.4-dba' for glob 'php7.*' Note, selecting 'php7.4-dev' for glob 'php7.*' Note, selecting 'php7.4-dom' for glob 'php7.*' Note, selecting 'php7.4-tidy' for glob 'php7.*' Note, selecting 'php7.4-ffi' for glob 'php7.*' Note, selecting 'php7.4-pcov' for glob 'php7.*' Note, selecting 'php7.0-thrift' for glob 'php7.*' Note, selecting 'php7.4-fpm' for glob 'php7.*' Note, selecting 'php7.4-ftp' for glob 'php7.*' Note, selecting 'php7.4-xmlreader' for glob 'php7.*' Note, selecting 'php7.4-gmp' for glob 'php7.*' Note, selecting 'php7.4-mysqli' for glob 'php7.*' Note, selecting 'php7.4-imagick' for glob 'php7.*' Note, selecting 'php7.4-sybase' for glob 'php7.*' Note, selecting 'php7.4-sysvmsg' for glob 'php7.*' Note, selecting 'php7.4-mongodb' for glob 'php7.*' Note, selecting 'php7.4-json' for glob 'php7.*' Note, selecting 'php7.2-sodium' for glob 'php7.*' Note, selecting 'php7.4-sass' for glob 'php7.*' Note, selecting 'php7.4-phar' for glob 'php7.*' Note, selecting 'php7.4-tokenizer' for glob 'php7.*' Note, selecting 'php7.4-igbinary' for glob 'php7.*' Note, selecting 'php7.4-pgsql' for glob 'php7.*' Note, selecting 'php7.4-lua' for glob 'php7.*' Note, selecting 'php7.4-curl' for glob 'php7.*' Note, selecting 'php7.4-phpdbg' for glob 'php7.*' Note, selecting 'php7.4-memcache' for glob 'php7.*' Note, selecting 'php7.4' for glob 'php7.*' Note, selecting 'php7.4-interbase' for glob 'php7.*' Note, selecting 'php7.4-shmop' for glob 'php7.*' Note, selecting 'php7.4-ldap' for glob 'php7.*' Note, selecting 'php7.4-radius' for glob 'php7.*' Note, selecting 'php7.4-pdo-mysql' for glob 'php7.*' Note, selecting 'php7.4-sysvsem' for glob 'php7.*' Note, selecting 'php7.4-sysvshm' for glob 'php7.*' Note, selecting 'php7.4-apcu-bc' for glob 'php7.*' Note, selecting 'php7.0-common' for glob 'php7.*' Note, selecting 'php7.4-uploadprogress' for glob 'php7.*' Note, selecting 'php7.4-pdo' for glob 'php7.*' Note, selecting 'php7.4-psr' for glob 'php7.*' Note, selecting 'php7.4-imap' for glob 'php7.*' Note, selecting 'php7.4-sockets' for glob 'php7.*' Note, selecting 'php7.4-ctype' for glob 'php7.*' Note, selecting 'php7.4-calendar' for glob 'php7.*' Note, selecting 'php7.4-intl' for glob 'php7.*' Note, selecting 'php7.4-rrd' for glob 'php7.*' Note, selecting 'php7.4-fileinfo' for glob 'php7.*' Note, selecting 'php7.4-geoip' for glob 'php7.*' Note, selecting 'php7.4-sqlite3' for glob 'php7.*' Note, selecting 'php7.4-odbc' for glob 'php7.*' Note, selecting 'php7.4-pdo-dblib' for glob 'php7.*' Note, selecting 'php7.4-xmlrpc' for glob 'php7.*' Note, selecting 'php7.4-redis' for glob 'php7.*' Note, selecting 'php7.4-yaml' for glob 'php7.*' Note, selecting 'php7.4-opcache' for glob 'php7.*' Note, selecting 'php7.4-snmp' for glob 'php7.*' Note, selecting 'php7.4-soap' for glob 'php7.*' Note, selecting 'php7.4-xml' for glob 'php7.*' Note, selecting 'php7.4-solr' for glob 'php7.*' Note, selecting 'php7.4-xsl' for glob 'php7.*' Note, selecting 'php7.4-yac' for glob 'php7.*' Note, selecting 'php7.4-oauth' for glob 'php7.*' Note, selecting 'php7.4-zip' for glob 'php7.*' Note, selecting 'php7.4-zmq' for glob 'php7.*' Note, selecting 'php7.4-pinba' for glob 'php7.*' Note, selecting 'php7.4-msgpack' for glob 'php7.*' Note, selecting 'php7.4-simplexml' for glob 'php7.*' Note, selecting 'php7.4-gearman' for glob 'php7.*' Note, selecting 'php7.4-ssh2' for glob 'php7.*' Note, selecting 'php7.4-pspell' for glob 'php7.*' Note, selecting 'php7.0-curl' for glob 'php7.*' Note, selecting 'php7.4-mysql' for glob 'php7.*' Note, selecting 'php7.4-propro' for glob 'php7.*' Note, selecting 'php7.4-mbstring' for glob 'php7.*' Note, selecting 'php7.4-readline' for glob 'php7.*' Note, selecting 'php7.4-amqp' for glob 'php7.*' Note, selecting 'php7.4-pdo-firebird' for glob 'php7.*' Note, selecting 'php7.2-thrift' for glob 'php7.*' Note, selecting 'php7.4-apcu' for glob 'php7.*' Note, selecting 'php7.4-exif' for glob 'php7.*' Note, selecting 'php7.4-xdebug' for glob 'php7.*' Note, selecting 'php7.4-memcached' for glob 'php7.*' Note, selecting 'php7.4-mysqlnd' for glob 'php7.*' Note, selecting 'php7.4-http' for glob 'php7.*' Note, selecting 'php7.4-pdo-sqlite' for glob 'php7.*' Note, selecting 'php7.4-common' for glob 'php7.*' Note, selecting 'php7.4-stomp' for glob 'php7.*' Note, selecting 'php7.4-raphf' for glob 'php7.*' Note, selecting 'php7.4-bcmath' for glob 'php7.*' Note, selecting 'php7.4-mailparse' for glob 'php7.*' Note, selecting 'php7.4-tideways' for glob 'php7.*' Note, selecting 'php7.4-gnupg' for glob 'php7.*' Note, selecting 'php7.4-pdo-pgsql' for glob 'php7.*' Note, selecting 'php7.4-posix' for glob 'php7.*' Note, selecting 'php7.4-iconv' for glob 'php7.*' Note, selecting 'php7.4-gmagick' for glob 'php7.*' Note, selecting 'php7.4-enchant' for glob 'php7.*' Note, selecting 'php7.4-gettext' for glob 'php7.*' Note, selecting 'php7.4-xmlwriter' for glob 'php7.*' Package 'php7.0-common' is not installed, so not removed Package 'php7.0-curl' is not installed, so not removed Package 'php7.2-sodium' is not installed, so not removed Note, selecting 'php7.4-common' instead of 'php7.4-calendar' Note, selecting 'php7.4-common' instead of 'php7.4-ctype' Note, selecting 'php7.4-common' instead of 'php7.4-exif' Note, selecting 'php7.4-common' instead of 'php7.4-ffi' Note, selecting 'php7.4-common' instead of 'php7.4-fileinfo' Note, selecting 'php7.4-common' instead of 'php7.4-ftp' Note, selecting 'php7.4-common' instead of 'php7.4-gettext' Note, selecting 'php7.4-common' instead of 'php7.4-iconv' Note, selecting 'php7.4-common' instead of 'php7.4-pdo' Note, selecting 'php7.4-common' instead of 'php7.4-phar' Note, selecting 'php7.4-common' instead of 'php7.4-posix' Note, selecting 'php7.4-common' instead of 'php7.4-shmop' Note, selecting 'php7.4-common' instead of 'php7.4-sockets' Note, selecting 'php7.4-common' instead of 'php7.4-sysvmsg' Note, selecting 'php7.4-common' instead of 'php7.4-sysvsem' Note, selecting 'php7.4-common' instead of 'php7.4-sysvshm' Note, selecting 'php7.4-common' instead of 'php7.4-tokenizer' Note, selecting 'php7.4-mysql' instead of 'php7.4-mysqli' Note, selecting 'php7.4-mysql' instead of 'php7.4-mysqlnd' Note, selecting 'php7.4-mysql' instead of 'php7.4-pdo-mysql' Note, selecting 'php7.4-odbc' instead of 'php7.4-pdo-odbc' Note, selecting 'php7.4-pgsql' instead of 'php7.4-pdo-pgsql' Note, selecting 'php7.4-sqlite3' instead of 'php7.4-pdo-sqlite' Note, selecting 'php7.4-xml' instead of 'php7.4-dom' Note, selecting 'php7.4-xml' instead of 'php7.4-simplexml' Note, selecting 'php7.4-xml' instead of 'php7.4-xmlreader' Note, selecting 'php7.4-xml' instead of 'php7.4-xmlwriter' Note, selecting 'php-amqp' instead of 'php7.4-amqp' Note, selecting 'php-apcu' instead of 'php7.4-apcu' Note, selecting 'php-apcu-bc' instead of 'php7.4-apcu-bc' Note, selecting 'php-ds' instead of 'php7.4-ds' Note, selecting 'php-gearman' instead of 'php7.4-gearman' Note, selecting 'php-geoip' instead of 'php7.4-geoip' Note, selecting 'php-gmagick' instead of 'php7.4-gmagick' Note, selecting 'php-gnupg' instead of 'php7.4-gnupg' Note, selecting 'php-http' instead of 'php7.4-http' Note, selecting 'php-igbinary' instead of 'php7.4-igbinary' Note, selecting 'php-imagick' instead of 'php7.4-imagick' Note, selecting 'php-lua' instead of 'php7.4-lua' Note, selecting 'php-mailparse' instead of 'php7.4-mailparse' Note, selecting 'php-memcache' instead of 'php7.4-memcache' Note, selecting 'php-memcached' instead of 'php7.4-memcached' Note, selecting 'php-mongodb' instead of 'php7.4-mongodb' Note, selecting 'php-msgpack' instead of 'php7.4-msgpack' Note, selecting 'php-oauth' instead of 'php7.4-oauth' Note, selecting 'php-pcov' instead of 'php7.4-pcov' Note, selecting 'php-pinba' instead of 'php7.4-pinba' Note, selecting 'php-propro' instead of 'php7.4-propro' Note, selecting 'php-ps' instead of 'php7.4-ps' Note, selecting 'php-psr' instead of 'php7.4-psr' Note, selecting 'php-radius' instead of 'php7.4-radius' Note, selecting 'php-raphf' instead of 'php7.4-raphf' Note, selecting 'php-redis' instead of 'php7.4-redis' Note, selecting 'php-rrd' instead of 'php7.4-rrd' Note, selecting 'php-sass' instead of 'php7.4-sass' Note, selecting 'php-solr' instead of 'php7.4-solr' Note, selecting 'php-ssh2' instead of 'php7.4-ssh2' Note, selecting 'php-stomp' instead of 'php7.4-stomp' Package 'php7.0-thrift' is not installed, so not removed Package 'php7.2-thrift' is not installed, so not removed Note, selecting 'php-tideways' instead of 'php7.4-tideways' Note, selecting 'php-uploadprogress' instead of 'php7.4-uploadprogress' Note, selecting 'php-uuid' instead of 'php7.4-uuid' Note, selecting 'php-xdebug' instead of 'php7.4-xdebug' Note, selecting 'php-yac' instead of 'php7.4-yac' Note, selecting 'php-yaml' instead of 'php7.4-yaml' Note, selecting 'php-zmq' instead of 'php7.4-zmq' Note, selecting 'php7.4-interbase' instead of 'php7.4-pdo-firebird' Note, selecting 'php7.4-sybase' instead of 'php7.4-pdo-dblib' Package 'php7.4' is not installed, so not removed Package 'php7.4-cgi' is not installed, so not removed Package 'php7.4-dev' is not installed, so not removed Package 'php7.4-gd' is not installed, so not removed Package 'php7.4-gmp' is not installed, so not removed Package 'php7.4-ldap' is not installed, so not removed Package 'php7.4-mysql' is not installed, so not removed Package 'php7.4-odbc' is not installed, so not removed Package 'php7.4-pgsql' is not installed, so not removed Package 'php7.4-pspell' is not installed, so not removed Package 'php7.4-snmp' is not installed, so not removed Package 'php7.4-sqlite3' is not installed, so not removed Package 'php7.4-tidy' is not installed, so not removed Package 'php7.4-xml' is not installed, so not removed Package 'php7.4-xmlrpc' is not installed, so not removed Package 'php7.4-bcmath' is not installed, so not removed Package 'php7.4-bz2' is not installed, so not removed Package 'php7.4-dba' is not installed, so not removed Package 'php7.4-enchant' is not installed, so not removed Package 'php7.4-fpm' is not installed, so not removed Package 'php7.4-imap' is not installed, so not removed Package 'php7.4-interbase' is not installed, so not removed Package 'php7.4-intl' is not installed, so not removed Package 'php7.4-phpdbg' is not installed, so not removed Package 'php7.4-soap' is not installed, so not removed Package 'php7.4-sybase' is not installed, so not removed Package 'php7.4-xsl' is not installed, so not removed Package 'php7.4-zip' is not installed, so not removed The following packages will be REMOVED: php7.4-cli* php7.4-common* php7.4-curl* php7.4-json* php7.4-mbstring* php7.4-opcache* php7.4-readline* 0 upgraded, 0 newly installed, 7 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] Y (Reading database ... 65835 files and directories currently installed.) Purging configuration files for php7.4-json (7.4.3-4ubuntu2.18) ... Purging configuration files for php7.4-common (7.4.3-4ubuntu2.18) ... dpkg: warning: while removing php7.4-common, directory '/etc/php/7.4/mods-available' not empty so not removed Purging configuration files for php7.4-curl (7.4.3-4ubuntu2.18) ... Purging configuration files for php7.4-readline (7.4.3-4ubuntu2.18) ... Purging configuration files for php7.4-mbstring (7.4.3-4ubuntu2.18) ... Purging configuration files for php7.4-cli (7.4.3-4ubuntu2.18) ... Purging configuration files for php7.4-opcache (7.4.3-4ubuntu2.18) ... wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ sudo apt-get autoclean Reading package lists... Done Building dependency tree Reading state information... Done wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ sudo apt-get autoremove Reading package lists... Done Building dependency tree Reading state information... Done 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ sudo dpkg -l | grep PHP rc php-common 2:75 all Common files for PHP packages
3、参考:How to Install and Run PHP 8.x on Ubuntu 20.04。添加 PHP PPA 存储库。 使用以下命令安装 PHP 8.1。
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ sudo apt install software-properties-common Reading package lists... Done Building dependency tree Reading state information... Done software-properties-common is already the newest version (0.99.9.11). software-properties-common set to manually installed. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ sudo add-apt-repository ppa:ondrej/php Co-installable PHP versions: PHP 5.6, PHP 7.x, PHP 8.x and most requested extensions are included. Only Supported Versions of PHP (http://php.net/supported-versions.php) for Supported Ubuntu Releases (https://wiki.ubuntu.com/Releases) are provided. Don't ask for end-of-life PHP versions or Ubuntu release, they won't be provided. Debian oldstable and stable packages are provided as well: https://deb.sury.org/#debian-dpa You can get more information about the packages at https://deb.sury.org IMPORTANT: The <foo>-backports is now required on older Ubuntu releases. BUGS&FEATURES: This PPA now has a issue tracker: https://deb.sury.org/#bug-reporting CAVEATS: 1. If you are using php-gearman, you need to add ppa:ondrej/pkg-gearman 2. If you are using apache2, you are advised to add ppa:ondrej/apache2 3. If you are using nginx, you are advised to add ppa:ondrej/nginx-mainline or ppa:ondrej/nginx PLEASE READ: If you like my work and want to give me a little motivation, please consider donating regularly: https://donate.sury.org/ WARNING: add-apt-repository is broken with non-UTF-8 locales, see https://github.com/oerdnj/deb.sury.org/issues/56 for workaround: # LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php More info: https://launchpad.net/~ondrej/+archive/ubuntu/php Press [ENTER] to continue or Ctrl-c to cancel adding it. Hit:1 https://deb.nodesource.com/node_18.x focal InRelease Get:2 http://ppa.launchpad.net/ondrej/php/ubuntu focal InRelease [23.9 kB] Hit:3 http://archive.ubuntu.com/ubuntu focal InRelease Get:4 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB] Get:5 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB] Get:6 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 Packages [115 kB] Get:7 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [2229 kB] Get:8 http://archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB] Get:9 http://security.ubuntu.com/ubuntu focal-security/main Translation-en [358 kB] Get:10 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main Translation-en [37.5 kB] Fetched 3100 kB in 10s (301 kB/s) Reading package lists... Done wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ sudo apt update Hit:1 http://security.ubuntu.com/ubuntu focal-security InRelease Hit:2 http://archive.ubuntu.com/ubuntu focal InRelease Hit:3 http://ppa.launchpad.net/ondrej/php/ubuntu focal InRelease Hit:4 https://deb.nodesource.com/node_18.x focal InRelease Hit:5 http://archive.ubuntu.com/ubuntu focal-updates InRelease Hit:6 http://archive.ubuntu.com/ubuntu focal-backports InRelease Reading package lists... Done Building dependency tree Reading state information... Done 6 packages can be upgraded. Run 'apt list --upgradable' to see them. wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$
4、安装 PHP 8.1 成功。如图1
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ sudo apt install php8.1 wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ php -v PHP 8.1.18 (cli) (built: Apr 14 2023 04:39:24) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.18, Copyright (c) Zend Technologies with Zend OPcache v8.1.18, Copyright (c), by Zend Technologies
1 条回复
[…] 8、参考:在 WSL2 中的 Ubuntu-20.04 中卸载 PHP 7.4,然后安装 PHP 8 […]