我面临的问题是 PHP 的最新更新包与实际运行的包不匹配。
最近我通过运行以下命令更新了我的 Ubuntu 服务器:
apt-get update && apt-get upgrade
在输出中我注意到安装了正确的软件包版本:
Unpacking php7.1-fpm (7.1.33-1+ubuntu18.04.1+deb.sury.org+1) over (PHP Version 7.1.25-1+ubuntu18.04.1+deb.sury.org+1) ...
我通过运行以下命令来控制已安装的版本:
apt-cache madison php7.1-fpm
php7.1-fpm | 7.1.33-1+ubuntu18.04.1+deb.sury.org+1 | http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 Packages
但是当我phpinfo()
从 php-fpm 套接字运行时,我仍然看到以前安装的版本:
PHP Version 7.1.25-1+ubuntu18.04.1+deb.sury.org+1
我尝试过什么?
- 重启
php7.1-fpm
。 - 重新启动 Nginx(位于 PHP fpm 顶部)。
编辑1
$ which php
/usr/bin/php
$ ls -al /usr/bin | grep php
php -> /etc/alternatives/php
php7.1
$ ls -al /etc/alternatives | grep php
php -> /usr/bin/php7.1
php.1.gz -> /usr/share/man/man1/php7.1.1.gz
$ /usr/bin/php7.1 -v
PHP 7.1.25-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Dec 7 2018 08:15:52) ( NTS )
编辑2
$ dpkg -l 'php*'|grep ^ii
ii php-common 2:69+ubuntu18.04.1+deb.sury.org+2+php7.3 all Common files for PHP packages
ii php-geoip 1.1.1-2+ubuntu18.04.1+deb.sury.org+10 amd64 GeoIP module for PHP
ii php-igbinary 3.0.1+2.0.8-1+ubuntu18.04.1+deb.sury.org+1 amd64 igbinary PHP serializer
ii php-memcached 3.1.3+2.2.0-1+ubuntu18.04.1+deb.sury.org+1 amd64 memcached extension module for PHP, uses libmemcached
ii php-msgpack 2.0.3+0.5.7-1+ubuntu18.04.1+deb.sury.org+1 amd64 PHP extension for interfacing with MessagePack
ii php-redis 5.0.2+4.3.0-2+ubuntu18.04.1+deb.sury.org+1 amd64 PHP extension for interfacing with Redis
ii php7.1 7.1.33-1+ubuntu18.04.1+deb.sury.org+1 all server-side, HTML-embedded scripting language (metapackage)
ii php7.1-cli 7.1.25-1+ubuntu18.04.1+deb.sury.org+1 amd64 command-line interpreter for the PHP scripting language
ii php7.1-common 7.1.25-1+ubuntu18.04.1+deb.sury.org+1 amd64 documentation, examples and common module for PHP
ii php7.1-curl 7.1.25-1+ubuntu18.04.1+deb.sury.org+1 amd64 CURL module for PHP
ii php7.1-fpm 7.1.25-1+ubuntu18.04.1+deb.sury.org+1 amd64 server-side, HTML-embedded scripting language (FPM-CGI binary)
ii php7.1-gd 7.1.25-1+ubuntu18.04.1+deb.sury.org+1 amd64 GD module for PHP
ii php7.1-gmp 7.1.25-1+ubuntu18.04.1+deb.sury.org+1 amd64 GMP module for PHP
ii php7.1-intl 7.1.25-1+ubuntu18.04.1+deb.sury.org+1 amd64 Internationalisation module for PHP
ii php7.1-json 7.1.25-1+ubuntu18.04.1+deb.sury.org+1 amd64 JSON module for PHP
ii php7.1-mbstring 7.1.25-1+ubuntu18.04.1+deb.sury.org+1 amd64 MBSTRING module for PHP
ii php7.1-mcrypt 7.1.25-1+ubuntu18.04.1+deb.sury.org+1 amd64 libmcrypt module for PHP
ii php7.1-mysql 7.1.25-1+ubuntu18.04.1+deb.sury.org+1 amd64 MySQL module for PHP
ii php7.1-opcache 7.1.25-1+ubuntu18.04.1+deb.sury.org+1 amd64 Zend OpCache module for PHP
ii php7.1-readline 7.1.25-1+ubuntu18.04.1+deb.sury.org+1 amd64 readline module for PHP
ii php7.1-sqlite3 7.1.25-1+ubuntu18.04.1+deb.sury.org+1 amd64 SQLite3 module for PHP
ii php7.1-xml 7.1.25-1+ubuntu18.04.1+deb.sury.org+1 amd64 DOM, SimpleXML, WDDX, XML, and XSL module for PHP
ii php7.1-zip 7.1.25-1+ubuntu18.04.1+deb.sury.org+1 amd64 Zip module for PHP
答案1
已安装软件包列表仅显示php7.1
版本 7.1.33,但并非所有子软件包都升级到 7.1.33。您可能希望升级php7.1-cli
并php7.1-fpm
一次性升级所有依赖软件包,因为它们具有更严格的版本依赖性。
您可能希望apt-cache policy
在将来使用,因为apt-cache madison
显示可用的软件包但未安装在系统上:
[jollyroger@desktop:~]% apt-cache policy vim-tiny
vim-tiny:
Installed: 2:8.1.0875-5+b1
Candidate: 2:8.1.2136-1
Version table:
2:8.1.2136-1 990
990 http://deb.debian.org/debian sid/main amd64 Packages
*** 2:8.1.0875-5+b1 100
100 /var/lib/dpkg/status
2:8.1.0875-5 500
500 http://deb.debian.org/debian buster/main amd64 Packages
请注意已安装行以及标有 的行***
。
答案2
根据评论中@jollyroger 的建议,我强制apt-get
升级 PHP 的所有子包。
apt-get upgrade php7.1-cli php7.1-common php7.1-curl php7.1-fpm php7.1-gd php7.1-gmp php7.1-intl php7.1-json php7.1-mbstring php7.1-mcrypt php7.1-mysql php7.1-opcache php7.1-readline php7.1-sqlite3 php7.1-xml php7.1-zip
然后所有包都像 charm 一样更新:
$ dpkg -l 'php*'|grep ^ii
ii php-common 2:69+ubuntu18.04.1+deb.sury.org+2+php7.3 all Common files for PHP packages
ii php-geoip 1.1.1-2+ubuntu18.04.1+deb.sury.org+10 amd64 GeoIP module for PHP
ii php-igbinary 3.0.1+2.0.8-1+ubuntu18.04.1+deb.sury.org+1 amd64 igbinary PHP serializer
ii php-memcached 3.1.3+2.2.0-1+ubuntu18.04.1+deb.sury.org+1 amd64 memcached extension module for PHP, uses libmemcached
ii php-msgpack 2.0.3+0.5.7-1+ubuntu18.04.1+deb.sury.org+1 amd64 PHP extension for interfacing with MessagePack
ii php-redis 5.0.2+4.3.0-2+ubuntu18.04.1+deb.sury.org+1 amd64 PHP extension for interfacing with Redis
ii php7.1 7.1.33-1+ubuntu18.04.1+deb.sury.org+1 all server-side, HTML-embedded scripting language (metapackage)
ii php7.1-cli 7.1.33-1+ubuntu18.04.1+deb.sury.org+1 amd64 command-line interpreter for the PHP scripting language
ii php7.1-common 7.1.33-1+ubuntu18.04.1+deb.sury.org+1 amd64 documentation, examples and common module for PHP
ii php7.1-curl 7.1.33-1+ubuntu18.04.1+deb.sury.org+1 amd64 CURL module for PHP
ii php7.1-fpm 7.1.33-1+ubuntu18.04.1+deb.sury.org+1 amd64 server-side, HTML-embedded scripting language (FPM-CGI binary)
ii php7.1-gd 7.1.33-1+ubuntu18.04.1+deb.sury.org+1 amd64 GD module for PHP
ii php7.1-gmp 7.1.33-1+ubuntu18.04.1+deb.sury.org+1 amd64 GMP module for PHP
ii php7.1-intl 7.1.33-1+ubuntu18.04.1+deb.sury.org+1 amd64 Internationalisation module for PHP
ii php7.1-json 7.1.33-1+ubuntu18.04.1+deb.sury.org+1 amd64 JSON module for PHP
ii php7.1-mbstring 7.1.33-1+ubuntu18.04.1+deb.sury.org+1 amd64 MBSTRING module for PHP
ii php7.1-mcrypt 7.1.33-1+ubuntu18.04.1+deb.sury.org+1 amd64 libmcrypt module for PHP
ii php7.1-mysql 7.1.33-1+ubuntu18.04.1+deb.sury.org+1 amd64 MySQL module for PHP
ii php7.1-opcache 7.1.33-1+ubuntu18.04.1+deb.sury.org+1 amd64 Zend OpCache module for PHP
ii php7.1-readline 7.1.33-1+ubuntu18.04.1+deb.sury.org+1 amd64 readline module for PHP
ii php7.1-sqlite3 7.1.33-1+ubuntu18.04.1+deb.sury.org+1 amd64 SQLite3 module for PHP
ii php7.1-xml 7.1.33-1+ubuntu18.04.1+deb.sury.org+1 amd64 DOM, SimpleXML, WDDX, XML, and XSL module for PHP
ii php7.1-zip 7.1.33-1+ubuntu18.04.1+deb.sury.org+1 amd64 Zip module for PHP
$ php -v
PHP 7.1.33-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Oct 26 2019 19:29:18) ( NTS )