打工人 发表于 2026-10-22 17:08:11

我对 PHP 5.4 修复 CVE-2026-109618 和 CVE-2026-109619 的过程

1 、下载:从 https://museum.php.net/php5/php-5.4.45.tar.gz 下载 PHP 5.4 的最新版本,从 https://github.com/vperetti/php-cve-2026-109618-109619-backports 下载 patch 文件
2 、打补丁:将php-5.4.45 目录php-5.4-CVE-2026-109618-109619.patch 文件放到同一个目录下,进入 php-5.4.45 目录,然后patch -p1 < ../php-5.4-CVE-2026-109618-109619.patch
3 、配置编译参数:在原来的 PHP 5.4 里,php -i | grep Configure 看到编译参数,比如我的是./configure --prefix=/www/server/php/54--with-config-file-path=/www/server/php/54/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir=/usr/local/freetype --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local/curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl=/usr/local/openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-intl --build=arm-linux
4 、编译:然后通过 make -j$(nproc) 进行编译我的是 4 核,也可以 make -j3 ,这样留给其他程序一点 CPU 资源
5 、停止原来的 PHP-FPM ,并备份原来的目录
6 、安装:make install
会输出Installing PHP CLI binary:      /www/server/php/54/bin/Installing PHP CLI man page:      /www/server/php/54/php/man/man1/Installing PHP FPM binary:      /www/server/php/54/sbin/Installing PHP FPM config:      /www/server/php/54/etc/Installing PHP FPM man page:      /www/server/php/54/php/man/man8/Installing PHP FPM status page:      /www/server/php/54/php/fpm/Installing PHP CGI binary:      /www/server/php/54/bin/Installing PHP CGI man page:      /www/server/php/54/php/man/man1/Installing build environment:   /www/server/php/54/lib/php/build/Installing header files:          /www/server/php/54/include/php/Installing helper programs:       /www/server/php/54/bin/program: phpizeprogram: php-configInstalling man pages:             /www/server/php/54/php/man/man1/page: phpize.1page: php-config.1Installing PEAR environment:      /www/server/php/54/lib/php/ Archive_Tar    - already installed: 1.3.12 Console_Getopt - already installed: 1.3.1 Structures_Graph- already installed: 1.0.4 XML_Util       - already installed: 1.2.3 PEAR         - already installed: 1.9.5Warning! a PEAR user config file already exists from a previous PEAR installation at '/root/.pearrc'. You may probably want to remove it.Wrote PEAR system config file at: /www/server/php/54-patch/etc/pear.confYou may want to add: /www/server/php/54/lib/php to your php.ini include_path/www/server/php/php-5.4.45/build/shtool install -c ext/phar/phar.phar /www/server/php/54/binln -s -f /www/server/php/54/bin/phar.phar /www/server/php/54/bin/pharInstalling PDO headers:          /www/server/php/54/include/php/ext/pdo/
如果原来的 php.ini 修改了的,就复制到新的里面
7 、重新启动 PHP-FPM


⚠️内容来自互联网,如有侵权请点击反馈!侵权投诉

SYS宇晖 发表于 2026-10-22 17:08:34

5.4 都还在打补丁,这是宝塔老机器吧?打之前最好先 php -v 记下版本,patch 完再跑一遍你的业务脚本验证,光看编译过不算数。另外问下这 patch 是官方 backport 还是社区做的,来源靠不靠谱很关键。
[这只是一个小尾巴]

SanS三石 发表于 2026-10-22 18:30:10

5.4 这老古董还在维护,够拼的。问下 configure 参数是直接照抄 php -i 里的吗?建议先 patch --dry-run 跑一遍,别 hunk 失败把源码搞乱了,打完记得重载 fpm。
[论坛助手]

纯牛马 发表于 2026-10-22 16:41:53

第 3 步的 php -i | grep Configure 的输出是 Configure Command =>'./configure''--prefix=/www/server/php/54' '--with-config-file-path=/www/server/php/54/etc' '--enable-fpm' '--with-fpm-user=www' '--with-fpm-group=www' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-iconv-dir' '--with-freetype-dir=/usr/local/freetype' '--with-jpeg-dir' '--with-png-dir' '--with-zlib' '--with-libxml-dir=/usr' '--enable-xml' '--disable-rpath' '--enable-bcmath' '--enable-shmop' '--enable-sysvsem' '--enable-inline-optimization' '--with-curl=/usr/local/curl' '--enable-mbregex' '--enable-mbstring' '--with-mcrypt' '--enable-ftp' '--with-gd' '--enable-gd-native-ttf' '--with-openssl=/usr/local/openssl' '--with-mhash' '--enable-pcntl' '--enable-sockets' '--with-xmlrpc' '--enable-zip' '--enable-soap' '--with-gettext' '--disable-fileinfo' '--enable-intl' '--build=arm-linux'带有引号的,复制到 AI 对话框里,让 AI 处理一下就好

joker 发表于 2026-10-22 16:46:05

./configure 的时候配置到其他目录,比如 --prefix=/www/server/php/54-patch ,那么日志等会写入到这个目录里,启动的时候会报错,会写入到 /www/server/php/54-patch/var/log/slow.log ,中间目录不存在。而且通过 phpinfo 看到extension_dir        /www/server/php/54-patch/lib/php/extensions/no-debug-non-zts-20100525include_path        .:/www/server/php/54-patch/lib/php所以还是直接 --prefix=/www/server/php/54 即可,在 make install 直接备份原目录并停止旧的 PHP-FPM 进程

困💤 发表于 2026-10-22 16:46:41

不知道能不能抵御漏洞,反正重新编译后的 PHP 5.4 能正常运行

joker 发表于 2026-10-22 16:50:15

需要一个确认,不然心里打鼓

江户川柯南 发表于 2026-10-22 16:57:02

上面的 php -i | grep Configure 写错了,应该是 php -i | grep Configuration

卷王 发表于 2026-10-22 17:04:14

php5.6.9nts /CGI/FastCGI windows 也是这个思路吗?

江户川柯南 发表于 2026-10-22 17:05:29

改了啥呢? 确认修复了吗

卷王 发表于 2026-10-22 17:08:28

版本太老啦。

🐛冬瓜 发表于 2026-10-22 17:36:53

@herozzm #4 确认不了,你可以去 https://github.com/vperetti/php-cve-2026-109618-109619-backports 看看 patch 文件是怎么写的

🐛冬瓜 发表于 2026-10-22 17:37:43

@yjd #6 不知道,我没在 windows 上编译过 PHP

joker 发表于 2026-10-22 17:38:29

@chenzhg33 #7 通过 https://github.com/vperetti/php-cve-2026-109618-109619-backports 下载的 patch 修改源码,然后用源码编译,不知道修复了没有,我也不知道怎么验证

困💤 发表于 2026-10-22 17:40:01

不要用 https://github.com/openai/php2shell-checker 的脚本进行验证,https://github.com/openai/php2shell-checker/blob/main/skills/phpcheck-url/scripts/phpcheck.js 这个脚本只是检查 PHP 的版本号而已

江户川柯南 发表于 2026-10-22 18:02:53

@Seanfuck #8 古董项目了,还在用 mysql_connect 这个函数

卷王 发表于 2026-10-22 16:41:53

第 3 步的 php -i | grep Configure 的输出是 Configure Command =>'./configure''--prefix=/www/server/php/54' '--with-config-file-path=/www/server/php/54/etc' '--enable-fpm' '--with-fpm-user=www' '--with-fpm-group=www' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-iconv-dir' '--with-freetype-dir=/usr/local/freetype' '--with-jpeg-dir' '--with-png-dir' '--with-zlib' '--with-libxml-dir=/usr' '--enable-xml' '--disable-rpath' '--enable-bcmath' '--enable-shmop' '--enable-sysvsem' '--enable-inline-optimization' '--with-curl=/usr/local/curl' '--enable-mbregex' '--enable-mbstring' '--with-mcrypt' '--enable-ftp' '--with-gd' '--enable-gd-native-ttf' '--with-openssl=/usr/local/openssl' '--with-mhash' '--enable-pcntl' '--enable-sockets' '--with-xmlrpc' '--enable-zip' '--enable-soap' '--with-gettext' '--disable-fileinfo' '--enable-intl' '--build=arm-linux'带有引号的,复制到 AI 对话框里,让 AI 处理一下就好
页: [1]
查看完整版本: 我对 PHP 5.4 修复 CVE-2026-109618 和 CVE-2026-109619 的过程