You can apply security patches to older PHP versions without upgrading to the latest PHP version.
You can apply updates for security patches for PHP 5.0 to 8.1
I am Arshid, a PHP core contributor. I can help you update PHP for security patches. Feel free to email: [email protected]
My profile: https://github.com/arshidkv12
How to update PHP 7.4?
Here, we’ll see how to apply security patches to PHP 7.4. You can use the same method for other PHP versions as well.
Step 1: Download the PHP 7.4 backport source code ZIP file.
|
1 |
wget https://github.com/shivammathur/php-src-backports/archive/refs/heads/PHP-7.4-security-backports.zip |
Step 2: Extract the ZIP file
|
1 2 |
unzip PHP-7.4-security-backports.zip cd php-src-backports-PHP-7.4-security-backports |
Step 3: Install the build dependencies
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
sudo apt update sudo apt install -y \ build-essential \ autoconf \ bison \ re2c \ pkg-config \ git \ libxml2-dev \ libsqlite3-dev \ libssl-dev \ libcurl4-openssl-dev \ libonig-dev \ libreadline-dev \ libzip-dev \ zlib1g-dev |
Step 4: Enter the following command to generate the build script
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
./buildconf --force ./configure \ --prefix=/etc/php/7.4/ \ --with-apxs2=/usr/bin/apxs \ --with-config-file-path=/etc/php/7.4/apache2 \ --with-config-file-scan-dir=/etc/php/7.4/apache2/conf.d \ --enable-cli \ --enable-bcmath \ --enable-exif \ --enable-gd \ --enable-intl \ --enable-mbstring \ --enable-soap \ --enable-sockets \ --enable-shmop \ --enable-sysvmsg \ --enable-sysvsem \ --enable-sysvshm \ --enable-pcntl \ --enable-mysqlnd \ --with-bz2 \ --with-curl \ --with-ffi \ --with-freetype \ --with-gettext \ --with-gmp \ --with-jpeg \ --with-ldap \ --with-mysqli=mysqlnd \ --with-openssl \ --with-password-argon2 \ --with-pdo-mysql=mysqlnd \ --with-pdo-pgsql \ --with-pgsql \ --with-readline \ --with-sodium \ --with-xsl \ --with-zip \ --with-zlib \ --with-webp |
Step 5: Now, you can start to compile
|
1 |
make -j"$(nproc)" |
Step 5: Connect the generated libs/libphp7.so to Apache or Nginx
Edit the /etc/apache2/mods-available/php7.4.load file.
|
1 2 |
sudo vi /etc/apache2/mods-available/php7.4.load LoadModule php7_module /var/www/html/test/php-src-backports-PHP-7.4-security-backports/libs/libphp7.so |
Step 6: Restart the server.
|
1 |
sudo systemctl restart apache2 |
Finished! Your PHP installation is now updated with the latest security patches. Feel free to PM [email protected]

