CodeCodeStudy
V2EX  ›  PHP

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

  •  
  •   CodeCodeStudy · 3h 45m ago · 533 views

    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: phpize program: php-config Installing man pages: /www/server/php/54/php/man/man1/ page: phpize.1 page: php-config.1 Installing PEAR environment: /www/server/php/54/lib/php/ [PEAR] Archive_Tar - already installed: 1.3.12 [PEAR] Console_Getopt - already installed: 1.3.1 [PEAR] Structures_Graph- already installed: 1.0.4 [PEAR] XML_Util - already installed: 1.2.3 [PEAR] PEAR - already installed: 1.9.5 Warning! 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.conf You 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/bin ln -s -f /www/server/php/54/bin/phar.phar /www/server/php/54/bin/phar Installing PDO headers: /www/server/php/54/include/php/ext/pdo/

    如果原来的 php.ini 修改了的,就复制到新的里面

    7 、重新启动 PHP-FPM

    13 replies  •  2026-10-22 18:02:53 +08:00
    CodeCodeStudy
        1
    CodeCodeStudy  
    OP
       3h 43m ago
    第 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 处理一下就好
    CodeCodeStudy
        2
    CodeCodeStudy  
    OP
       3h 39m ago
    ./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-20100525
    include_path .:/www/server/php/54-patch/lib/php

    所以还是直接 --prefix=/www/server/php/54 即可,在 make install 直接备份原目录并停止旧的 PHP-FPM 进程
    CodeCodeStudy
        3
    CodeCodeStudy  
    OP
       3h 39m ago
    不知道能不能抵御漏洞,反正重新编译后的 PHP 5.4 能正常运行
    herozzm
        4
    herozzm  
       3h 35m ago
    需要一个确认,不然心里打鼓
    CodeCodeStudy
        5
    CodeCodeStudy  
    OP
       3h 28m ago
    上面的 php -i | grep Configure 写错了,应该是 php -i | grep Configuration
    yjd
        6
    yjd  
       3h 21m ago
    php5.6.9nts /CGI/FastCGI windows 也是这个思路吗?
    chenzhg33
        7
    chenzhg33  
       3h 20m ago
    改了啥呢? 确认修复了吗
    Seanfuck
        8
    Seanfuck  
       3h 17m ago
    版本太老啦。
    CodeCodeStudy
        9
    CodeCodeStudy  
    OP
       2h 48m ago
    @herozzm #4 确认不了,你可以去 https://github.com/vperetti/php-cve-2026-109618-109619-backports 看看 patch 文件是怎么写的
    CodeCodeStudy
        10
    CodeCodeStudy  
    OP
       2h 48m ago   ❤️ 1
    @yjd #6 不知道,我没在 windows 上编译过 PHP
    CodeCodeStudy
        11
    CodeCodeStudy  
    OP
       2h 47m ago
    @chenzhg33 #7 通过 https://github.com/vperetti/php-cve-2026-109618-109619-backports 下载的 patch 修改源码,然后用源码编译,不知道修复了没有,我也不知道怎么验证
    CodeCodeStudy
        12
    CodeCodeStudy  
    OP
       2h 45m ago
    CodeCodeStudy
        13
    CodeCodeStudy  
    OP
       2h 22m ago
    @Seanfuck #8 古董项目了,还在用 mysql_connect 这个函数
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3307 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 12:25 · PVG 20:25 · LAX 05:25 · JFK 08:25
    ♥ Do have faith in what you're doing.