How to Fix PHP2Shell (CVE-2026-109618 and CVE-2026-109619) on Any Server: Step by Step for PHP 8.2 to 8.5

Prashant Singh at his laptop next to a diagram showing the three steps to fix PHP2Shell: update PHP, restart PHP-FPM and check the site's PHP version

On 21 October 2026, the PHP project released PHP 8.5.12, 8.4.27, 8.3.36 and 8.2.35. These releases fix two critical bugs, CVE-2026-109618 and CVE-2026-109619, which security researchers have named PHP2Shell. Both bugs let an attacker run code on your server without logging in, according to the PHP security advisory on php.net (retrieved 2026-10-22). Any server that runs PHP for a website is affected, whether it sits on DigitalOcean, AWS, Contabo, Linode, Hetzner, Vultr or a rack in your own office.

I patched a DigitalOcean Droplet I look after soon after the advisory came out. It runs Ubuntu 22.04 with three PHP versions and a Laravel app, and it hit two problems on the way that I expect many of you will hit too. I’ve used that server as the example in a few places. Every step below works for PHP 8.2, 8.3, 8.4 and 8.5, with Apache or Nginx, on Ubuntu, Debian and the Red Hat family of systems.

Before you start: run the commands over SSH as a user with sudo rights. Wherever a command uses 8.3, change it to your own PHP version.

Key Takeaways

  • PHP 8.5.12, 8.4.27, 8.3.36 and 8.2.35 fix PHP2Shell, two remote code execution bugs rated 9.2 on CVSS v4.0 (PHP security advisory, October 2026).
  • Amazon Threat Intelligence logged a PHP2Shell exploitation attempt on 17 October 2026, four days before the fix came out, so patch today.
  • Ubuntu and Debian ship their own fixed builds with older looking version numbers. Compare the full package version with your distribution’s CVE page.
  • php -v prints the command line version, and your website can run a different one through PHP-FPM, so check both.
  • Restart PHP-FPM and the web server after the update. Queue workers need a restart too because they keep the old PHP loaded.

Table of Contents

What is PHP2Shell (CVE-2026-109618 and CVE-2026-109619)?

PHP2Shell is the name for two remote code execution bugs inside PHP itself. Both carry a CVSS v4.0 score of 9.2, which puts them in the critical band. The GitHub advisory for CVE-2026-109618 lists every release below 8.2.35, 8.3.36, 8.4.27 and 8.5.12 as affected (retrieved 2026-10-22). The attacker does not need an account on your site to try it.

CVE-2026-109618: code execution after an out of memory error

When PHP runs out of memory, it uses longjmp() to jump out of the request. If that jump happens while some internal request data is only half set up, the cleanup code later treats the broken data as valid. An attacker who can push PHP into that state can get their own code to run.

CVE-2026-109619: code execution through stale global state

A PHP worker holds on to some state between requests, things like error, session and extension data. With this bug, part of that state survives after its memory has been freed. The next request on the same worker can use the stale data before PHP resets it, and the GitHub advisory for CVE-2026-109619 says the PHP team confirmed session paths for it.

The php.net advisory names PHP-FPM, Apache with mod_php, php-cgi, FrankenPHP and LiteSpeed as affected. It calls mod_php the highest risk and mentions a demonstrated exploit where an unauthenticated request triggers the attack before any application code runs.

Reports of real attacks come from outside the PHP project. Amazon Threat Intelligence logged a PHP2Shell exploitation attempt against its MadPot honeypot network on 17 October 2026, four days before public disclosure, as reported by Help Net Security. Tenable’s PHP2Shell FAQ adds that Amazon now sees broad exploitation in the wild (both retrieved 2026-10-22). Treat every unpatched server as a target from today.

Your PHP branchFixed release from the PHP project
PHP 8.58.5.12
PHP 8.48.4.27
PHP 8.38.3.36
PHP 8.28.2.35 (security support ends 31 December 2026)
PHP 8.1 and olderNo release from the PHP project. See the PHP 8.1 section below.
Source: PHP security advisory, 21 October 2026, and the PHP supported versions page (both retrieved 2026-10-22)

Is your server affected, and who has to fix it?

If PHP serves web pages on the machine, it needs the fix. Who does the work depends on how you host:

Where your PHP runsWho installs the fixWhat you do
Shared hostingYour hosting companyCheck the PHP version in your control panel. Raise a ticket if it is still old.
VPS or cloud server (DigitalOcean, AWS EC2 or Lightsail, Contabo, Linode, Hetzner, Vultr, OVHcloud)YouFollow every step in this guide.
Dedicated serverYouSame as a VPS.
Server set up with Laravel Forge or PloiYouIt is an Ubuntu server underneath, so use the Ubuntu steps.
cPanel or Plesk serverYou, through the panelRun the panel update, then do Steps 5 to 7.
Docker containersYouPull the fixed PHP image, rebuild and redeploy.

If an agency set up your server and no longer looks after it, the patch is your job now. Make sure you hold the server login first. My guide on what to do when you inherit a Laravel app from an agency lists every account to take over.

Step 1: Take a backup before you touch PHP

Every cloud provider has a snapshot button. DigitalOcean, Contabo, Hetzner and Vultr call it Snapshots, AWS uses EBS snapshots or an AMI, and Linode has Backups. Take one before you change any package on production.

A snapshot rolls back the whole disk, and that includes any orders or sign ups that came in after you took it. So keep a separate copy of the database and your config files as well:

mkdir -p ~/pre-php-update

# Ubuntu and Debian
sudo cp -r /etc/php /etc/apache2 /etc/nginx ~/pre-php-update/ 2>/dev/null

# AlmaLinux, Rocky, RHEL, Amazon Linux
sudo cp -r /etc/php.ini /etc/php.d /etc/php-fpm.d /etc/httpd /etc/nginx ~/pre-php-update/ 2>/dev/null

# Your app and database
cp /path/to/your/app/.env ~/pre-php-update/
mysqldump -u your_db_user -p your_db_name > ~/pre-php-update/db.sql

The 2>/dev/null part hides errors for folders your server doesn’t have, so you can run the line as it is.

Step 2: Find every PHP version on your server

Many servers carry more than one PHP version, and each one needs the fix. My Droplet had 8.1 for an old site, 8.3 for the Laravel app and 8.5 as the terminal default. Start with the operating system and the PHP binaries:

cat /etc/os-release
php -v
ls /usr/bin/php*
systemctl list-units --type=service --all | grep -i php

On Ubuntu and Debian, ls /etc/php/ also shows one folder for each installed version. If you use Remi’s repository on a Red Hat family server, parallel versions live under /opt/remi/.

Next, find out which web server you run and whether Apache has mod_php loaded:

systemctl list-units --type=service | grep -E 'apache2|httpd|nginx|lsws'

# Ubuntu and Debian
sudo apache2ctl -M | grep -i php

# Red Hat family
sudo httpd -M | grep -i php

A line with php_module means mod_php is loaded, which the advisory rates as the highest risk. My Droplet had php_module and proxy_fcgi loaded together, so some sites went through PHP-FPM while mod_php sat inside Apache as well. A loaded module can still handle requests for any site or folder without a PHP-FPM handler, so patch it too.

Step 3: Find the PHP version your website uses

This one confused me on my own server. php -v printed PHP 8.5.12, while the Laravel site was running on PHP 8.3 the whole time. Both readings were right, because PHP runs in separate contexts on the same machine.

The CLI is the PHP you get in the terminal. Artisan, Composer, cron jobs and queue workers use it. PHP-FPM is the service that runs PHP for websites. Apache or Nginx hands each request to an FPM socket, and every site can point at a different socket, so the terminal and the website can run different versions.

Diagram showing the terminal running PHP 8.5 CLI while Apache sends Laravel website requests to the PHP 8.3 FPM socket on the same Ubuntu 22.04 server
The terminal and the website can run different PHP versions on one server.

To see which socket each site uses, search the web server config. Pick the line for your server:

# Apache on Ubuntu and Debian
sudo grep -R -nE 'fpm\.sock|SetHandler|ProxyPassMatch' /etc/apache2/sites-enabled/

# Apache on the Red Hat family
sudo grep -R -nE 'fpm\.sock|SetHandler|ProxyPassMatch' /etc/httpd/conf.d/

# Nginx on any system
sudo grep -R -n 'fastcgi_pass' /etc/nginx/

On Ubuntu and Debian the socket name carries the version, for example /run/php/php8.3-fpm.sock. Red Hat family servers often use a single /run/php-fpm/www.sock, which belongs to whichever php-fpm service is installed.

The surest check is to ask PHP through a real web request. On staging, create a file called php-version-check.php in your site’s public folder (for Laravel that is public, for WordPress it is the main folder):

<?php

echo PHP_VERSION;

Open https://your-domain.com/php-version-check.php in a browser and note the number, then delete the file straight away. Never leave a version check file or a phpinfo() page on a live site, because phpinfo() prints paths and settings an attacker can use.

If expose_php is on in php.ini, the response header tells you the same thing without a file:

curl -sI https://your-domain.com | grep -i x-powered-by

Step 4: Update PHP on your server

Jump to the part that matches your system. If you aren’t sure, the cat /etc/os-release output from Step 2 tells you.

Ubuntu and Debian

Your PHP comes from one of two places. The first is your distribution’s own packages. Ubuntu and Debian keep the old upstream number on these and backport the fix, so the version looks older than 8.3.36 even after you patch. Here are the fixed package versions from the Ubuntu CVE page and the Debian security tracker:

SystemPackageFixed package version
Ubuntu 26.04 LTSphp8.58.5.4-0ubuntu1.5
Ubuntu 24.04 LTSphp8.38.3.6-0ubuntu0.24.04.13
Ubuntu 22.04 LTSphp8.18.1.2-1ubuntu2.28
Ubuntu 20.04 LTSphp7.47.4.3-4ubuntu2.29+esm5 (Ubuntu Pro only)
Debian 13 (trixie)php8.48.4.27-1~deb13u1 (DSA-6574-1)
Debian 12 (bookworm)php8.28.2.35-1~deb12u1 (DLA-4848-1)
Source: Ubuntu CVE page and Debian security tracker for CVE-2026-109618 (both retrieved 2026-10-22)

The second place is a third party repository: the Ondřej Surý PPA on Ubuntu, or packages.sury.org on Debian. Most servers that run PHP 8.2 to 8.5 on Ubuntu 22.04 use it, and Laravel Forge and Ploi servers use Ubuntu too. Packages from these repositories follow the upstream numbers, so look for 8.3.36, 8.4.27 and so on.

Refresh the package list, see what is waiting, and check where each package comes from:

sudo apt update
apt list --upgradable 2>/dev/null | grep -i php
apt-cache policy php8.3-fpm

apt-cache policy prints an Installed and a Candidate version, plus the repository URL next to each one. On my Droplet the Candidate for php8.3-fpm was 8.3.36-1+ubuntu22.04.1+deb.sury.org+1. The part before the first hyphen matched the advisory, so I knew the PPA had the fix.

Now pick one of the two options. Option A installs every pending update on the server. I use it on most servers, because the other pending updates are usually security fixes as well:

sudo apt upgrade

Option B upgrades only one PHP version and its extensions, plus mod_php for that version if it is installed. Set the version once at the top, then run the second line. Run it again with each version you found in Step 2.

PHPV=8.3
sudo apt install --only-upgrade $(dpkg -l "php${PHPV}*" "libapache2-mod-php${PHPV}" 2>/dev/null | awk '/^ii/{print $2}')

PHPV only lasts for your current terminal session. If you open a new SSH window, set it again. Read the change list APT shows before you type Y.

AlmaLinux, Rocky Linux, RHEL and Amazon Linux

These systems use DNF. Check what is waiting, then upgrade every PHP package in one go:

sudo dnf check-update 'php*'
sudo dnf upgrade 'php*'
php -v

AlmaLinux announced patched PHP packages on 21 October 2026 in its PHP2Shell blog post. Red Hat tracks its own fix on the Red Hat CVE page. If your PHP comes from the volunteer-run Remi repository, the PHP advisory says Remi would not have updates on release day, so run dnf check-update again later and confirm the new version before you move on. With Remi’s parallel packages, each version has its own command such as php83 and its own service such as php83-php-fpm.

cPanel and WHM (EasyApache 4)

EasyApache 4 installs PHP as ea-php packages. As root, run the cPanel update or update those packages directly, then restart PHP-FPM and Apache:

/scripts/upcp
# or update only the PHP packages
dnf update 'ea-php*'

/scripts/restartsrv_apache_php_fpm
/scripts/restartsrv_httpd

/opt/cpanel/ea-php83/root/usr/bin/php -v

On older CentOS 7 servers, use yum in place of dnf. Change ea-php83 in the last line to check each version you have. If a build still shows a version below the fixed release, read the EasyApache 4 release notes on docs.cpanel.net.

Plesk

The Plesk support article on CVE-2026-109618 and CVE-2026-109619 lists fixed Plesk for Linux builds for PHP 8.2 to 8.5 and asks you to update Plesk (retrieved 2026-10-22). Go to Tools & Settings, then Updates, or use the command line:

plesk installer --select-release-current --upgrade-installed-components
systemctl restart plesk-php83-fpm
/opt/plesk/php/8.3/bin/php -v

Docker containers

The official php image on Docker Hub already had tags for the fixed releases when I checked, such as 8.3.36-alpine and 8.4.27-fpm-alpine (retrieved 2026-10-22). If your Dockerfile uses a moving tag like php:8.3-fpm, rebuild with a fresh pull. If it pins a patch number like php:8.3.28-fpm, change it to 8.3.36 first.

docker compose build --pull
docker compose up -d
docker compose exec app php -v

Replace app with the name of your PHP service in docker-compose.yml.

Shared hosting

Your hosting company installs the fix for you. Open the PHP version page in your control panel, or use the version check file from Step 3. If the number is still below the fixed release a day after the advisory, raise a support ticket and ask when they will patch.

Step 5: Restart PHP-FPM and your web server

PHP processes that are already running keep the old code in memory until they restart. Restart them yourself so you know it happened. Use the lines that match your system:

# Ubuntu and Debian (repeat for each PHP version)
PHPV=8.3
sudo systemctl restart php${PHPV}-fpm
sudo systemctl restart apache2     # or: sudo systemctl restart nginx

# Red Hat family
sudo systemctl restart php-fpm
sudo systemctl restart httpd       # or: sudo systemctl restart nginx

# LiteSpeed
sudo systemctl restart lsws

Then make sure each service came back up. Every line should print active:

systemctl is-active php8.3-fpm nginx

If a service fails, its log usually names the broken line or the missing extension:

sudo journalctl -u php8.3-fpm -n 100 --no-pager

Step 6: Restart queue workers and other long running PHP

Some PHP processes stay alive for hours, and they keep the old binary loaded the whole time. In a Laravel app, tell them to restart:

php artisan queue:restart          # plain queue workers
php artisan horizon:terminate      # if you use Horizon
php artisan octane:reload          # if you use Octane
sudo supervisorctl restart all     # anything else Supervisor runs

Supervisor brings each worker back up on the new binary. My guide to setting up and configuring Supervisor on AWS EC2 covers the full worker setup, and the same config works on any Linux host. A plain WordPress site has no workers, so it can skip this step.

While you are here, check that Supervisor and cron call the PHP version you expect. On a server with several versions, I name the binary in full so a change to the default never moves a worker by accident:

command=php8.3 /var/www/your-app/artisan queue:work --sleep=3 --tries=3

* * * * * cd /var/www/your-app && php8.3 artisan schedule:run >> /dev/null 2>&1

Step 7: Confirm the fix is live

Check every PHP binary on the server with one loop:

for p in /usr/bin/php[0-9]*; do echo -n "$p: "; $p -r 'echo PHP_VERSION, PHP_EOL;'; done

Red Hat family servers usually have a single php binary, so php -v is enough there. With Ubuntu or Debian’s own packages, this prints the old short number like 8.3.6 even after the fix. Check the full package version against the table in Step 4 instead:

dpkg -l | grep -E 'php[0-9.]+-fpm|libapache2-mod-php'

Then repeat the version check file from Step 3 for each website, and delete the file afterwards. The browser result is the one that tells you the site is safe.

Can’t update today? Interim measures from the PHP advisory

If you are waiting for a package or a maintenance window, the PHP advisory lists settings that block the attack paths known so far. The PHP team says these reduce exposure and do not make a server safe, so use them to cover a few hours and then update.

For CVE-2026-109618 (out of memory corruption)

  • Set memory_limit=-1 somewhere apps can’t override it, like php_admin_value in the FPM pool or the Apache config. Check that no pool, folder or app puts a finite limit back.
  • Set a low post_max_size: 8M if the app takes no uploads, 32M if it does. Keep upload_max_filesize below it.
  • Put a container or cgroup memory limit around PHP so the kernel kills only the runaway worker. The advisory warns against RLIMIT_AS and RLIMIT_DATA (what ulimit -v sets), because those can trigger the bug.

For CVE-2026-109619 (stale global state)

  • Set session.upload_progress.enabled=0 in php.ini or the FPM pool and restart every worker. ini_set() and .user.ini apply too late to help.
  • On PHP 8.5, set fatal_error_backtraces=0 as well.
  • Remove invalid or deprecated ini settings that print a warning on every request. Hiding the warning with display_errors or @ gives no protection.
  • Fix fatal errors and timeouts that a visitor can trigger, for example during upload or import processing.

In the FPM pool file, the changes look like this. The file is /etc/php/8.3/fpm/pool.d/www.conf on Ubuntu and Debian, and /etc/php-fpm.d/www.conf on the Red Hat family. If your app accepts uploads, use 32M and 30M for the two size limits.

php_admin_value[memory_limit] = -1
php_admin_value[post_max_size] = 8M
php_admin_value[upload_max_filesize] = 6M
php_admin_flag[session.upload_progress.enabled] = off

For the memory cap, open a systemd override with sudo systemctl edit php8.3-fpm (or php-fpm on the Red Hat family) and add the lines below. Size MemoryMax to your server’s RAM. OOMPolicy=continue keeps systemd from stopping the whole FPM service when the kernel kills one worker.

[Service]
MemoryMax=2G
OOMPolicy=continue
sudo systemctl daemon-reload
sudo systemctl restart php8.3-fpm

With mod_php, put the same values in the Apache virtual host using php_admin_value and php_admin_flag, then restart Apache.

What about PHP 8.1, 8.0 and 7.4?

The PHP project no longer releases these versions, and they are missing from the PHP supported versions page (retrieved 2026-10-22). Some distributions still patch them. Ubuntu 22.04 has a fixed php8.1 package, and Ubuntu 20.04 has a fixed php7.4 for Ubuntu Pro users, as the table in Step 4 shows. The PHP security team also published small source backports for 7.4, 8.0 and 8.1 for people who compile PHP themselves.

Before you trust an old version, run apt-cache policy php8.1-fpm (or dnf info php) to see which repository the package comes from, then check that repository’s security notice for both CVE numbers. If nothing uses the old version, remove it after you have checked every crontab and Supervisor config. Old cron lines that call /usr/bin/php8.1 directly are easy to miss, and they stop without any warning when the binary goes. Either way, plan the move to PHP 8.3 or newer. PHP 8.2 loses security support on 31 December 2026, so it buys you very little time.

Errors you may see during the update

“Package php5 is not available”

I hit this on my Droplet when I tried a pattern that matches every package named php plus a number:

sudo apt install --only-upgrade '?name(^php[0-9.]+$)'

Package php5 is not available
E: Package 'php5' has no installation candidate

The pattern searches every package name APT has heard of, and that list includes old names like php5 that other packages still mention. Ubuntu 22.04 has no installable php5, so APT rejected the whole command and upgraded nothing. Use Option A or Option B from Step 4 instead.

“Unable to locate package php8.4-fpm”

The version you typed isn’t installed or isn’t in your repositories. Run ls /etc/php/ to see the versions you have, and use those numbers in the commands.

502 Bad Gateway or 503 Service Unavailable after the restart

The web server can’t reach PHP-FPM. Either the FPM service didn’t start, or the socket path in the site config doesn’t match the real socket. Test the FPM config and look at the sockets that exist:

sudo php-fpm8.3 -t
systemctl status php8.3-fpm
ls -l /run/php/

On the Red Hat family, the commands are sudo php-fpm -t and ls -l /run/php-fpm/.

Apache warning AH00112: DocumentRoot does not exist

My Droplet printed this for an old staging site whose folder had been deleted. It does no harm to the patch, but it fills the logs you are about to read. Run sudo apache2ctl -S to list the virtual hosts, fix or disable the broken one, then run sudo apache2ctl configtest before you reload Apache. My post on Apache virtual hosts that are not redirecting covers more virtual host problems.

Check your server for signs of compromise

PHP2Shell was being tried in the wild before the patch existed, so spend twenty minutes looking for anything odd once the patch is in. Look back to at least 17 October 2026, the date of the first recorded attempt. Start with recent logins and scheduled tasks. Check the web server user’s crontab as well (www-data on Ubuntu and Debian, apache or nginx on the Red Hat family), because a web shell that wants to survive a reboot often hides there.

sudo last -a | head -20
sudo ls -la /etc/cron.d/
sudo crontab -l
sudo crontab -u www-data -l

Look at the processes using the most CPU, and at PHP files changed in the last seven days inside your web folders. On cPanel servers, sites live under /home/*/public_html, so search there too.

ps aux --sort=-%cpu | head -20
sudo find /var/www -name '*.php' -mtime -7 -ls

If you deploy from Git, git status --short in the app folder lists any file that doesn’t belong to your repository. These checks catch the obvious cases, and a proper forensic review goes much deeper. If you find signs that someone got in, keep the logs and take the server off the network if you can. Change passwords and keys from a different machine, then rebuild from a backup you know is clean.

How to keep PHP patched from now on

On Ubuntu and Debian, the unattended-upgrades package installs security updates on its own. Its default config only covers the distribution’s own repositories, so packages from the Ondřej Surý PPA or packages.sury.org get left out until you add their origin name. Find that name first:

sudo apt install unattended-upgrades
apt-cache policy | grep -i -E 'ondrej|sury'

The o= value in that output is the origin. For the Ubuntu PPA it reads LP-PPA-ondrej-php. Add it to /etc/apt/apt.conf.d/50unattended-upgrades, then do a dry run to see what would install:

Unattended-Upgrade::Origins-Pattern {
        "origin=LP-PPA-ondrej-php";
};

sudo unattended-upgrade --dry-run --debug

On the Red Hat family, dnf-automatic does the same job:

sudo dnf install dnf-automatic
sudo systemctl enable --now dnf-automatic-install.timer

I only switch automatic updates on for servers with tested backups. A PHP update can break an extension at 3 a.m. with nobody watching, so I want a restore I have already tried before I let updates run on their own.

A few habits keep the next advisory from turning into a late night:

  • Follow the php.net news feed and the security notices of every repository on the server.
  • Remove PHP versions that no site or script needs.
  • Keep Laravel, your Composer packages and any WordPress plugins updated.
  • Check the CLI version and the website version separately after every PHP update.
  • Restart queue workers whenever the PHP runtime changes.
  • Restore a backup at least once, so you know it works before you need it.

Cloudflare has deployed WAF rules for the known PHP2Shell exploit paths, according to Help Net Security. Patch anyway, because a WAF rule only covers the attack paths people know about so far. I’ve listed the other basics I set up on every server in my step by step website security guide, and if you are building a fresh server, start with my VPS setup guide for Laravel, PHP, Apache and MySQL.

Frequently Asked Questions

Is PHP2Shell being exploited in the wild?

Yes. Amazon Threat Intelligence logged an exploitation attempt against its MadPot honeypots on 17 October 2026, four days before the patch came out, and Tenable reports that Amazon now sees broad exploitation. The PHP advisory itself does not report attacks. Patch now and check the server for signs of access back to 17 October.

I am on shared hosting. Do I need to do anything?

Your hosting company installs the fix, so you do not run any commands. Check the PHP version in your control panel or with a one line PHP file that prints PHP_VERSION. If it is still below 8.2.35, 8.3.36, 8.4.27 or 8.5.12 a day after the advisory, raise a support ticket.

Does php -v show the PHP version my website uses?

No. php -v prints the default command line PHP. Your website runs on whichever PHP-FPM socket or module its Apache or Nginx config points to. On my server, the terminal reported PHP 8.5.12 while the Laravel site was still on PHP 8.3. Check the website version through a browser request.

Ubuntu 24.04 shows PHP 8.3.6 after the update. Is it still vulnerable?

Not if the full package version is 8.3.6-0ubuntu0.24.04.13 or later. Ubuntu keeps the old upstream number and backports the fix, so php -v prints 8.3.6 either way. Run dpkg -l and compare the package version with the Ubuntu CVE page for CVE-2026-109618.

Does restarting Apache or Nginx update PHP?

No. A restart only reloads what is already on disk. Install the patched packages first, then restart each PHP-FPM service you use and the web server. Restart Laravel queue workers as well, since long running workers keep the old PHP binary in memory until they stop.

Should I uninstall PHP 8.1?

Uninstall it once you have checked that no website, cron job, queue worker or script calls it. Ubuntu 22.04 ships a fixed php8.1 package, but the PHP project no longer releases 8.1, so outside Ubuntu a vendor backport is the only way to patch it. Moving to PHP 8.3 or newer is the safer long term plan.

Why did my PHP update fail with a php5 package error?

The APT pattern you used matched every package name that looks like php plus a number, and that included php5. Ubuntu 22.04 has no installable php5, so APT stopped and upgraded nothing. Upgrade with sudo apt upgrade, or upgrade one PHP version at a time by package name.

Need help patching your server?

I’ve been running Laravel and PHP in production since 2014, on DigitalOcean, AWS and other Linux hosts. Maybe your server has PHP versions nobody remembers installing, or an app the team is scared to touch. Send me a message on WhatsApp with your hosting provider, your OS version and the output of php -v, and I’ll tell you what to patch first.

Written by Prashant Singh, a freelance Laravel, PHP and AI automation developer based in Kanpur, India. Published 22 October 2026.


Sources