PHP2Shell (CVE-2026-109618 / CVE-2026-109619) is a critical security problem in PHP itself that lets attackers take over web servers. Every website that runs PHP should be updated to 8.5.12, 8.4.27, 8.3.36, 8.2.35 or newer as soon as possible. Read our PHP2Shell check and patch guide.
Disclaimer: before attempting to update the PHP version of your website we would highly recommend that you make a full backup of it, just in case anything goes wrong.
Debian is one of the most popular operating systems for web servers, and MX Linux is built directly on top of it. This guide shows you how to update PHP using either Debian's own packages or the well-known repository at packages.sury.org. The examples use PHP 8.4, so replace 8.4 with whichever supported branch you want to install.
Run the following command in a terminal or over SSH to see the PHP version used on the command line. Your web server may be configured to use a different version, so we also recommend checking your live site with our free PHP version checker.
php -v
Before you change anything, save a list of the PHP packages that are installed so that you can install the same extensions for the new version:
dpkg -l | grep php | awk '{print $2}' > ~/php-packages.txt
Each stable Debian release includes a single PHP branch, and the Debian security team keeps it patched for as long as that release is supported. Debian 12 (Bookworm) ships PHP 8.2 and Debian 13 (Trixie) ships PHP 8.4. If your release already offers a branch that is still supported, keeping the system updated is all you need to do:
sudo apt update
sudo apt upgrade
Moving from one Debian release to the next is also a reliable way to get a newer PHP branch, although it is a larger job that upgrades the whole operating system.
Ondřej Surý, who maintains the PHP packages in Debian itself, also runs a separate repository that offers every supported PHP branch for current Debian releases. It allows several PHP versions to be installed side by side. Add the repository and its signing key with the commands below:
sudo apt update
sudo apt install -y lsb-release ca-certificates curl
sudo curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
sudo dpkg -i /tmp/debsuryorg-archive-keyring.deb
sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/debsuryorg-archive-keyring.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
sudo apt update
Then install the new version along with the extensions your website uses. Check the list you saved earlier and add any extensions that are not in this example.
sudo apt install php8.4 php8.4-cli php8.4-fpm php8.4-common php8.4-mysql php8.4-xml php8.4-mbstring php8.4-curl php8.4-zip php8.4-gd php8.4-intl php8.4-bcmath
MX Linux uses the same codenames as the Debian release it is based on, so the commands above work without any changes. Deepin is different, because it uses its own release names and its own repositories. The lsb_release -sc command will therefore not return a name that packages.sury.org recognises, and mixing Debian packages into Deepin can cause conflicts. On Deepin we recommend that you use the PHP version from the Deepin repositories, or run your website inside a container or a virtual machine running Debian.
If you use Apache with the mod_php module, disable the old module, enable the new one and restart Apache. Replace 8.2 with the version you are moving away from.
sudo apt install libapache2-mod-php8.4
sudo a2dismod php8.2
sudo a2enmod php8.4
sudo systemctl restart apache2
If you use Apache with PHP-FPM, swap the enabled configuration instead:
sudo a2disconf php8.2-fpm
sudo a2enconf php8.4-fpm
sudo systemctl restart php8.4-fpm apache2
If you use Nginx, edit your site's configuration file in /etc/nginx/sites-available/ so that the fastcgi_pass line uses unix:/run/php/php8.4-fpm.sock, then run sudo nginx -t and sudo systemctl reload nginx.
Make sure that the php command, which is used by Composer, cron jobs and other scripts, runs the same version as your website:
sudo update-alternatives --set php /usr/bin/php8.4
Remember that settings are stored separately for each version in /etc/php/8.4/, so copy across any changes you made to php.ini. When you are happy that the site works, you can remove the old packages with sudo apt purge 'php8.2*' followed by sudo apt autoremove.
If your site shows errors after the upgrade, our guide to common PHP errors after upgrading explains the usual causes. It may also be time to call in a professional to assist, so check out our listings of PHP developers that can help upgrade or maintain your website.