我正在为一位正在赶上更新的客户提供建议,并且最近将 Ubuntu 连同软件包从 18.04LTs 更新到了 v20.04LTS。他们使用的是 Ubuntu 附带的 PHP 7.2 (7.2.34-38+ubuntu18.04.1+deb.sury.org+1)。更新后,memcached 扩展不再可用。我的印象是,这收到了向后移植的安全更新,我们依赖于此,直到今年晚些时候整个应用程序被替换,并希望转移到一些托管托管。
通过网络上的 phpinfo() 查看配置,我看到:
配置文件 (php.ini) 路径 /etc/php/7.2/apache2
扩展目录 /usr/lib/php/20170718
/usr/lib/php/20170718 的内容
$ ls /usr/lib/php/20170718/
calendar.so ftp.so mbstring.so pdo.so soap.so wddx.so zip.so
ctype.so gd.so mysqli.so phar.so sockets.so xmlreader.so
curl.so gettext.so mysqlnd.so posix.so sysvmsg.so xmlrpc.so
dom.so iconv.so newrelic.so readline.so sysvsem.so xml.so
exif.so intl.so opcache.so shmop.so sysvshm.so xmlwriter.so
fileinfo.so json.so pdo_mysql.so simplexml.so tokenizer.so xsl.so
以及下面目录的内容
/usr/lib/php$ ls
20170718 20210902 7.2 8.1 packaging php-helper sessionclean
20190902 20220829 7.4 8.2 php-fpm-socket-helper php-maintscript-helper
在这里看到版本和日期 api 数字似乎有点令人困惑,我假设它们之间发生了某种混淆。但我真的不知道它们之间有什么区别。
当我尝试安装 php-memcached 时:
$ sudo apt install php-memcached
Reading package lists... Done
Building dependency tree
Reading state information... Done
php-memcached is already the newest version (3.2.0+2.2.0-3+ubuntu18.04.1+deb.sury.org+1).
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
当我尝试运行任何 php-cli 命令时,我也注意到了这一点:
$ php --version
PHP Warning: PHP Startup: Unable to load dynamic library 'igbinary.so' (tried: /usr/lib/php/20170718/igbinary.so (/usr/lib/php/20170718/igbinary.so: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/igbinary.so.so (/usr/lib/php/20170718/igbinary.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'msgpack.so' (tried: /usr/lib/php/20170718/msgpack.so (/usr/lib/php/20170718/msgpack.so: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/msgpack.so.so (/usr/lib/php/20170718/msgpack.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'memcached.so' (tried: /usr/lib/php/20170718/memcached.so (/usr/lib/php/20170718/memcached.so: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/memcached.so.so (/usr/lib/php/20170718/memcached.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP 7.2.34-38+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Feb 14 2023 18:27:17) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.34-38+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
所以大概是 igbinary、msgpack 和 memcached 丢失了。
问题是,更新过程中出了什么问题,如何正确安装这些软件包?
更新:最终我认为这就是修复它的原因:
# add-apt-repository ppa:ondrej/php
# sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4f4ea0aae5267a6c
# apt-get install php-memcached php7.2-memcached
# apt-get install php-igbinary php7.2-igbinary # probably redundant to the above
# apt-get install libapache2-mod-php7.2
# systemctl restart apache2
虽然我不确定它最初是如何破裂的。