Zero-Downtime PHP 8.2 Upgrade on Debian 11: From Legacy 7.4 to Modern 8.2 Without Breaking WordPress

Rey Posted on 16 days ago 42 Views


If your Debian 11 box is still humming along on PHP 7.4, you’ve probably noticed the security nag screens and WordPress’ not-so-subtle hints that 7.4 is officially dead.

This guide walks you through a smooth, production-safe PHP 8.2 upgrade on Debian 11—no downtime, no missing MySQL extensions, no tears.

SEO keywords: Debian 11 upgrade to PHP 8.2, migrate PHP 7.4 to PHP 8.2 Debian, install PHP 8.2 MySQL extension on Debian 11, WordPress missing MySQL extension fix.


1. TL;DR for the Impatient

  1. Add Ondřej Surý repo.
  2. Install PHP 8.2 + extensions.
  3. Point Nginx/Apache to php8.2-fpm.sock.
  4. Re-install php8.2-mysql if WordPress whines.
  5. Purge 7.4 and go grab coffee.

2. Back Up First (Seriously)

# List every PHP 7.4 package
dpkg -l | grep php7.4 | tee ~/php74-list.txt

# Copy configs
sudo cp -r /etc/php/7.4 ~/php74-backup

3. Add the Surý Repository

sudo apt update && sudo apt install -y lsb-release apt-transport-https ca-certificates wget
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
sudo apt update

4. Install PHP 8.2 and Friends

sudo apt install -y \
  php8.2 php8.2-cli php8.2-fpm \
  php8.2-mysql php8.2-curl php8.2-xml \
  php8.2-gd php8.2-mbstring php8.2-opcache \
  php8.2-zip php8.2-apcu

5. Switch Web Server to 8.2

Nginx

sudo nano /etc/nginx/sites-available/your-site

Replace

fastcgi_pass unix:/run/php/php7.4-fpm.sock;

with

fastcgi_pass unix:/run/php/php8.2-fpm.sock;

Then

sudo nginx -t && sudo systemctl reload nginx

Apache

sudo a2disconf php7.4-fpm
sudo a2enconf php8.2-fpm
sudo systemctl restart apache2

6. Common Gotchas & Fixes

6.1 CLI Still Shows 8.4?

sudo apt remove --purge php8.4*
sudo apt install --reinstall php8.2-cli
sudo update-alternatives --set php /usr/bin/php8.2

6.2 php-fpm8.2 Won’t Start

Error:

Unable to globalize '/etc/php/7.4/fpm/pool.d/*.conf'

Fix:

sudo nano /etc/php/8.2/fpm/php-fpm.conf

Change

include=/etc/php/7.4/fpm/pool.d/*.conf

to

include=/etc/php/8.2/fpm/pool.d/*.conf
sudo php-fpm8.2 -t && sudo systemctl restart php8.2-fpm

6.3 WordPress: “Your PHP installation appears to be missing the MySQL extension”

Re-install the exact matching extension:

sudo apt install --reinstall php8.2-mysql php8.2-pdo php8.2-common

Verify:

php8.2 -m | grep -E 'mysqli|pdo_mysql|mysqlnd'

7. Clean Up PHP 7.4

sudo apt remove --purge php7.4*
sudo apt autoremove -y
sudo rm -rf /etc/php/7.4 /usr/lib/php/20190902

8. Final Checklist

  • php -vPHP 8.2.x
  • php -m lists mysqli, pdo_mysql, mysqlnd
  • WordPress Site Health → all green
  • No more scary security emails

9. One-Liner Script (Copy-Paste)

#!/bin/bash
set -e
sudo apt update
sudo apt install -y php8.2 php8.2-{fpm,cli,mysql,common,xml,curl,gd,mbstring,opcache,zip,apcu}
sudo apt remove --purge php7.4* -y
sudo apt autoremove -y
sudo systemctl restart php8.2-fpm nginx
echo "PHP 8.2 upgrade complete"

That’s it—Debian 11 upgrade to PHP 8.2 done, WordPress happy, and you can finally sleep without dreaming of EOL warnings. Happy coding!

This author has not provided a description.
Last updated on 2025-08-27