Upgrade Ubuntu 22.04 to 26.04 on EC2 with PHP-FPM and MySQL
Upgrade an EC2 web server from Ubuntu 22.04 to 26.04 in place, keep every site on its own PHP version, and get MySQL 8.4 past the native-password check.
AWS Health has started warning about Ubuntu 22.04 LTS on EC2. According to the AWS notice and AWS’s Ubuntu 22.04 LTS FAQ (opens in a new tab), Canonical ends standard support for 22.04 on May 31, 2027. After that date, new security bugs in 22.04 may not be patched unless you upgrade or attach Ubuntu Pro. AWS lists two fixes: upgrade to 24.04 or 26.04, or convert the instance to Ubuntu Pro 22.04 with AWS License Manager (opens in a new tab).
I took one EC2 web server from Ubuntu 22.04 to 26.04 in place. It runs about a dozen PHP sites on Apache, with
PHP 7.4 and 8.3 from Ondřej Surý’s repository and MySQL on the same machine. Every site kept its PHP version, and
MySQL moved from 8.0 to 8.4. I hit five traps between apt and do-release-upgrade, and this note covers each one
with the exact error. If you are patching PHP from the same repository, see
patching PHP CVE-2026-109618 and CVE-2026-109619 too.
TL;DR: Back up with an AMI, move PHP from the deprecated Launchpad PPA to packages.sury.org, protect your
versioned PHP packages, remove the generic php and libapache2-mod-php* packages, then run do-release-upgrade
twice (22.04 to 24.04, then 24.04 to 26.04). Answer N to “Remove obsolete packages?”, and add
loose-mysql_native_password = ON before the second hop.
This applies if:
- Server: an EC2 instance on Ubuntu 22.04 LTS, upgraded in place rather than rebuilt.
- Web stack: Apache 2.4 sends PHP to PHP-FPM, the separate process pool that runs PHP for the web server. Each site can use its own PHP version.
- PHP: installed from Surý’s repository, either the Launchpad PPA
ppa:ondrej/phporpackages.sury.org. - Database: Ubuntu’s own MySQL 8.0 package on the same server.
- Access:
sudoon the server, and rights in the EC2 console to create images and edit the security group.
Is my EC2 instance affected?
Your instance is affected if it runs Ubuntu 22.04, the release called jammy. The AWS Health Dashboard lists the
instances under the event’s Affected resources. On the server itself, ask the OS:
Read-only
grep -E '^(VERSION|VERSION_CODENAME)=' /etc/os-releaseuname -rVERSION="22.04.5 LTS (Jammy Jellyfish)"VERSION_CODENAME=jammy6.8.0-1063-awsWithout the Health API, run the AWS CLI from your workstation or CloudShell to list your instances and their AMI IDs,
then look up each AMI ID to read its name. AMI names that contain jammy are 22.04. Run this in every region you use:
Read-only · runs where the AWS CLI is configured
aws ec2 describe-instances \ --query 'Reservations[].Instances[].[InstanceId,ImageId,Tags[?Key==`Name`]|[0].Value,State.Name]' \ --output tableaws ec2 describe-images --include-deprecated --image-ids ami-0123456789abcdef0 \ --query 'Images[].[ImageId,Name]' --output tableWhat changes with each release
As of November 2026, these are the support dates from the AWS notice and the versions I saw on my host (after
Step 6 updated 22.04 from 6.8.0-1063-aws to 6.8.0-1070-aws):
| Release | Codename | Standard support ends | MySQL from Ubuntu | AWS kernel I got |
|---|---|---|---|---|
| Ubuntu 22.04 | jammy |
May 31, 2027 | 8.0.46 | 6.8.0-1070-aws |
| Ubuntu 24.04 | noble |
May 2029 | 8.0.46 | 7.0.0-1018-aws |
| Ubuntu 26.04 | resolute |
May 2031 | 8.4.13 | 7.0.0-1018-aws |
| Ubuntu Pro 22.04 | jammy |
May 2032 | 8.0 | unchanged |
do-release-upgrade moves one LTS at a time, so 22.04 to 26.04 is two upgrades in a row. Ubuntu 24.04.5’s HWE kernel
already ships the 26.04 (7.0) AWS kernel, so the first hop changes little for a PHP server. The second hop is the hard
one, because MySQL jumps to 8.4.
The five traps I hit
If you are already mid-upgrade and staring at an error, jump straight to it:
| When | Exact error or surprise | Fix |
|---|---|---|
apt update |
changed its 'Label' value from 'PPA for PHP' to 'PPA for PHP (deprecated)' |
Step 2: switch to packages.sury.org |
apt full-upgrade |
Switch to mpm prefork for package libapache2-mod-php8.3 |
Step 5: remove libapache2-mod-php* |
Hop 1 (24.04) |
Could not find the release announcement (404 on EC2 regional mirror) |
Step 8: point APT at archive.ubuntu.com |
Hop 1 (24.04) |
_test_and_fail_on_tpm_fde crash on Command '['snap', 'list']' |
Step 9: re-enable snapd |
Hop 2 (26.04) |
Unable to upgrade MySQL (mysql_native_password), then unknown variable 'mysql_native_password=ON' on 8.0 |
Step 12: loose-mysql_native_password = ON |
Which path should I take?
- Upgrade to Ubuntu 24.04 and stop: the smallest change. MySQL stays on 8.0, and you have support until May 2029.
- Continue to Ubuntu 26.04: the longest support. Do it only once you know your sites log in to MySQL 8.4, which Step 12 covers.
- Ubuntu Pro 22.04: nothing on the server changes, but you pay a licence fee. Use it for a server you can’t touch before May 2027.
I went to 26.04 because the owner wanted one upgrade project, not two. If your sites use old PHP code, I’d stop at 24.04 first and run it for a week.
Before you start
- Create an AMI that reboots the instance (leave No reboot unticked, or keep Reboot instance ticked in the newer console). AWS shuts the OS down cleanly so MySQL’s files are consistent. On my host the server was down for under a minute, and each image was Available within about 15 minutes.
- Dump every database as well. An AMI rolls back the whole server and loses everything written since. A dump lets you restore only the data.
- Make sure you can get in without SSH. Enable the EC2 Serial Console (opens in a new tab)
in the account settings, and log in once to check that your user’s password works. Session Manager needs the SSM
agent, which on Ubuntu is a snap—if
snapdwas disabled on your host (as in Step 9), Session Manager won’t connect either. - Pick a quiet window. Apache, PHP-FPM and MySQL restart several times. On my host each hop took 17 to 40 minutes from the checkpoint to the reboot, plus the PHP steps after it.
Create the rollback AMI
In the EC2 console, open Instances, select the server, and choose Actions → Image and templates →
Create image (opens in a new tab). Give it a clear name
such as pre-noble-2026-11-30, leave No reboot unticked (or keep Reboot instance ticked in the newer console),
check under Instance volumes that every attached EBS disk is included, and click Create image. Under
Images → AMIs, wait until Status changes from Pending to Available before changing anything on the
server—the instance itself boots back up in about a minute while EBS finishes the snapshot in the background.
Or run the same step with the AWS CLI (create-image reboots by default when --no-reboot is omitted):
Reboots the instance briefly · runs where the AWS CLI is configured
ami=$(aws ec2 create-image \ --instance-id i-0123456789abcdef0 \ --name "pre-noble-$(date +%F-%H%M)" \ --description "Ubuntu 22.04 rollback before 24.04 upgrade" \ --query 'ImageId' --output text)echo "AMI: $ami"aws ec2 describe-images --image-ids "$ami" --query 'Images[].[ImageId,State]' --output tableRe-run describe-images until State reads available (aws ec2 wait image-available --image-ids "$ami" polls for
you, though it times out after 10 minutes on larger disks).
If you ever need to roll back, EC2’s Replace root volume (opens in a new tab) (Actions → Monitor and troubleshoot → Replace root volume, then select Image and paste the AMI ID) swaps the root disk back to that AMI while keeping the same instance ID, private IP, Elastic IP and security group.
Dump every database
--single-transaction dumps InnoDB tables consistently while the sites stay up. Lock down ~/pre-upgrade with -m 700
so local users can’t read the SQL dump, and check the last line to confirm it finished:
Writes a backup file only
mkdir -p -m 700 ~/pre-upgradedump=~/pre-upgrade/all-db-$(date +%F-%H%M).sql.gzsudo mysqldump --all-databases --single-transaction --routines --events --triggers | gzip > "$dump"ls -lh "$dump"zcat "$dump" | tail -1-- Dump completed on 2026-11-26 22:08:54My dump was 12 MB compressed (85 MB uncompressed) against a 567 MB /var/lib/mysql folder, which is normal because dumps
omit indexes, binary logs and free space. Compare the server’s database list with the dump’s:
sudo -vdiff <(sudo mysql --defaults-file=/etc/mysql/debian.cnf -N -e 'SHOW DATABASES' | sort) \ <(zcat "$dump" | grep -oP '^CREATE DATABASE /\*!32312 IF NOT EXISTS\*/ `\K[^`]+' | sort)Only information_schema, performance_schema and sys should appear (mysqldump skips those on purpose). I used
debian.cnf because sudo mysql was refused on my host while sudo mysqldump read a login from
/etc/mysql/conf.d/mysqldump.cnf. Pass --defaults-file=/etc/mysql/debian.cnf to mysqldump too if yours asks for a
password.
Part 1: Prepare the server on 22.04
The release upgrade went smoothly once the server was clean. Most of my problems came from the packages around PHP, so fix those on 22.04, where a mistake is quick to undo.
Step 1: Record which PHP version each site uses
Read-only
Each site’s vhost hands PHP to an FPM socket with SetHandler. Save that map before you change anything. Use grep -R, not grep -r: the files in sites-enabled are symlinks, and -r skips them without a word.
mkdir -p -m 700 ~/pre-upgradesudo grep -RHiE 'proxy:unix|SetHandler' /etc/apache2/sites-enabled/ /etc/apache2/conf-enabled/ \ | tee ~/pre-upgrade/vhost-php-map.txtsystemctl list-units 'php*-fpm*' --all --no-pager | tee ~/pre-upgrade/fpm-services.txtsudo apache2ctl -M 2>/dev/null | grep -iE 'mpm|php|proxy_fcgi'/etc/apache2/sites-enabled/example.com.conf: SetHandler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost" mpm_event_module (shared) proxy_fcgi_module (shared)On my host, ten sites used PHP 7.4 and two used PHP 8.3, and Apache ran in event mode with no PHP module loaded. Every later check compares against this.
Step 2: Move PHP from the Launchpad PPA to packages.sury.org
Changes an APT source
The first apt update stopped with this:
E: Repository 'https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy InRelease' changed its 'Label' value from 'PPA for PHP' to 'PPA for PHP (deprecated)'Answering y only accepts the new label. The PPA is deprecated, so replace the source with the repository at
packages.sury.org. Recent updates from the PPA install its signing key, debsuryorg-archive-keyring, so check whether
it is already there:
ls -l /usr/share/keyrings/debsuryorg-archive-keyring.gpgls /etc/apt/sources.list.d/If you have no ondrej file and no key, the server doesn’t use this repository, and you can skip to
Step 4. If you have an ondrej file but
/usr/share/keyrings/debsuryorg-archive-keyring.gpg is missing, install the keyring first:
curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.debsudo dpkg -i /tmp/debsuryorg-archive-keyring.debOtherwise, move the PPA file aside and add the new source. rel is the only line to change: jammy now, noble
on 24.04, resolute on 26.04.
rel=jammysudo mkdir -p /root/old-aptsudo mv /etc/apt/sources.list.d/ondrej-ubuntu-php-*.list* /root/old-apt/echo "deb [signed-by=/usr/share/keyrings/debsuryorg-archive-keyring.gpg] https://packages.sury.org/php/ $rel main" \ | sudo tee /etc/apt/sources.list.d/sury-php.listsudo apt-get updateapt-cache policy php8.3-fpm | head -6The mv also moves any leftover focal file from an older 20.04 upgrade. On my host there were two. apt-cache policy should name https://packages.sury.org/php jammy/main, and the candidate version changes its suffix from
+deb.sury.org to +debsuryorg.
Step 3: Protect the PHP packages your sites use
Changes APT's package marks
APT marks each package “manual” (you chose it) or “auto” (pulled in as a dependency). Auto packages leave with apt autoremove, and the release upgrader can remove them too. On my host, php8.3-bcmath showed up under “no longer
required”, and so did the repository’s own key.
Set the PHP branches your sites use from Step 1. keep is the
only line to change:
keep='^php(7\.4|8\.3)-'apt-mark showauto | grep -E "$keep"apt-mark showauto | grep -E "$keep" | xargs -r sudo apt-mark manualsudo apt-mark manual debsuryorg-archive-keyringapt-mark showauto | grep -E "$keep|^debsuryorg" || echo 'all protected'all protectedThis only changes APT’s records. Nothing is installed, removed or restarted.
Step 4: Remove the generic PHP packages
Removes packages
Packages without a version number, such as php, php-curl and libapache2-mod-php, always point at the newest PHP.
On my host they pulled in PHP 8.4 on one update and wanted PHP 8.6 on the next, though no site used either. Your sites
depend on the versioned packages, so the generic ones can go. Keep php-common, which the versioned packages need.
mapfile -t generic < <(dpkg -l | awk '/^ii/ && $2 ~ /^(php|libapache2-mod-php)(-[a-z0-9]+)?$/ && $2 != "php-common" {print $2}')printf '%s\n' "${generic[@]}"sudo apt-get -s remove "${generic[@]}" | grep -E '^(Inst|Remv)'The simulation (-s) changes nothing. If generic is empty, skip to Step 5.
Otherwise check that every Remv line is one of the generic names, with no php7.4-*, php8.3-* or composer. Then
remove them without -y, so you read the list once more:
sudo apt remove "${generic[@]}"Step 5: Keep Apache on PHP-FPM
Removes packages, restarts Apache
This is the surprise that worried me most. After a routine apt full-upgrade, the log said:
info: Switch to mpm prefork for package libapache2-mod-php8.3Module mpm_event disabled.Enabling module mpm_prefork.Enabling module php8.3.Why it happens
The libapache2-mod-php8.3 package switched Apache to prefork mode and loaded PHP 8.3 inside Apache. The sites still
answered, because each vhost’s SetHandler sends PHP to FPM. But Apache was no longer the server I had tested, and
prefork uses more memory per visitor. On the update before that, the same package had failed with Could not switch to prefork MPM, not enabling PHP 8.3, so the outcome depends on the order packages are installed.
How to fix it
If Step 1 showed that every site uses FPM, remove the Apache PHP modules so no update can flip it again. First see what is installed and what removing it would take:
mapfile -t modphp < <(dpkg -l | awk '/^ii/ && $2 ~ /^libapache2-mod-php[0-9]/ {print $2}')printf '%s\n' "${modphp[@]}"sudo apt-get -s remove "${modphp[@]}" | grep -E '^(Inst|Remv)'If nothing is printed, check sudo apache2ctl -M and skip to Step 6. Otherwise
only libapache2-mod-php* lines should appear. Put Apache back in event mode if it was switched (apache2ctl -M calls
PHP modules php_module or php7_module instead of the versioned name, so the loop reads the real names from
mods-enabled):
for f in /etc/apache2/mods-enabled/php*.load; do [ -e "$f" ] || continue sudo a2dismod "$(basename "$f" .load)"doneif [ -e /etc/apache2/mods-enabled/mpm_prefork.load ]; then sudo a2dismod mpm_prefork && sudo a2enmod mpm_eventfisudo apache2ctl configtest && sudo systemctl restart apache2configtest must print Syntax OK, or Apache is not restarted. Then remove the modules and check Apache once more:
sudo apt remove "${modphp[@]}"sudo apache2ctl -M 2>/dev/null | grep -iE 'mpm|php|proxy_fcgi' mpm_event_module (shared) proxy_fcgi_module (shared)Step 6: Bring 22.04 fully up to date
Installs updates, restarts services
The upgrader expects a fully updated system. Simulate first, then install:
sudo apt-get updatesudo apt-get -s full-upgrade | grep -E '^(Inst|Remv)' | grep -E 'Remv|php|libapache2'sudo apt full-upgrade[ -f /var/run/reboot-required ] && echo 'reboot needed' || echo 'no reboot needed'There should be no Remv line for PHP, and no new PHP version such as php8.6. If a new kernel came in, reboot and
check that uname -r shows it.
Part 2: Upgrade 22.04 to 24.04
On my host, the first two runs failed before touching a single package, and the third finished in 17 minutes:
-
Attempt 1
EC2 mirror 404
The regional EC2 mirror lacked the 24.04 upgrader tarball and blamed an overloaded server.
-
Attempt 2
snapd crash
The 24.04 TPM disk-encryption check ran
snap liston a host withsnapddisabled. -
Attempt 3
24.04 in 17 min
With
archive.ubuntu.comandsnapdback on, the hop completed cleanly. -
Post-reboot
PHP on noble
Re-enabling
packages.sury.orgmoved PHP 7.4 and 8.3 onto 24.04 builds.
Step 7: Run the pre-flight checks
Read-only
grep -v '^#' /etc/update-manager/release-upgrades | grep .apt-mark showholddf -h / /bootls /etc/apt/sources.list.d/snap list >/dev/null && echo 'snap: ok'sudo do-release-upgrade -c[DEFAULT]Prompt=ltsFilesystem Size Used Avail Use% Mounted on/dev/root 146G 74G 72G 51% //dev/root 146G 74G 72G 51% /sury-php.listsnap: okChecking for a new Ubuntu releaseNew release '24.04.5 LTS' available.Run 'do-release-upgrade' to upgrade to it.apt-mark showhold should print nothing, / should have at least 5 GB free (plus room on /boot if it is a separate
partition), and snap: ok must appear—if it is missing, fix it with
Step 9 before you start. I didn’t run that check the first time, and
it crashed the upgrader. The mirror problem in
Step 8 doesn’t show up here at all: do-release-upgrade -c
worked on my host, and the real run still failed.
Step 8: Point APT at archive.ubuntu.com for the upgrade
Changes the Ubuntu APT source
My first do-release-upgrade stopped before it changed anything:
Checking for a new Ubuntu releaseCould not find the release announcementThe server may be overloaded.The server wasn’t overloaded. EC2 instances use a regional mirror such as <region>.ec2.archive.ubuntu.com, and on my
host that mirror returned 404 Not Found for the upgrader’s files while archive.ubuntu.com returned 200 OK. Test
yours:
mirror=$(grep -oE 'http://[a-z0-9-]+\.ec2\.archive\.ubuntu\.com' /etc/apt/sources.list | head -1)for host in ${mirror:+"$mirror"} http://archive.ubuntu.com; do for f in ReleaseAnnouncement noble.tar.gz; do printf '%s %s: ' "$host" "$f" curl -sI -m 20 "$host/ubuntu/dists/noble-updates/main/dist-upgrader-all/current/$f" | head -1 donedoneIf the regional mirror fails, switch the Ubuntu lines to the main archive. The security.ubuntu.com lines stay as they
are. cloud-init writes sources.list only on an instance’s first boot, so it won’t undo this.
sudo cp /etc/apt/sources.list ~/pre-upgrade/sources.list.jammy-backupsudo sed -i 's#http://[a-z0-9-]*\.ec2\.archive\.ubuntu\.com/ubuntu/#http://archive.ubuntu.com/ubuntu/#g' /etc/apt/sources.listgrep -v '^\s*#' /etc/apt/sources.list | grep .sudo apt-get update 2>&1 | grep -E '^(Err|E:|W:)' || echo 'no errors'To undo it, copy the backup back over /etc/apt/sources.list.
Step 9: Turn snapd back on if it was disabled
Starts a service
My second attempt got further, then Ubuntu’s crash reporter appeared with Please choose (S/V/K/I/C):. Press K to
keep the report without sending it. The upgrader’s log, /var/log/dist-upgrade/main.log, showed why:
self._test_and_fail_on_tpm_fde()subprocess.CalledProcessError: Command '['snap', 'list']' returned non-zero exit status 1.Before it calculates anything, the 24.04 upgrader checks for TPM-backed disk encryption by running snap list.
Someone had disabled snapd on my host, so the command failed and the upgrader crashed instead of carrying on. Nothing
had changed yet: the server was still on 22.04, and dpkg --audit was clean.
Check whether snapd is disabled or masked:
systemctl is-enabled snapd.service snapd.socketsystemctl is-active snapd.service snapd.socketIf they say disabled and inactive, start snapd. If they say masked, run sudo systemctl unmask snapd.service snapd.socket first.
sudo systemctl enable --now snapd.socket snapd.servicesnap listsnap list should print a table of snaps. You can disable snapd again after the upgrade if you want it off.
Step 10: Run the upgrade and answer the prompts
Upgrades the OS, restarts everything
First, allow TCP port 1022 from your own IP in the instance’s security group. When you upgrade over SSH, the upgrader starts a spare SSH server on that port, in case the main one breaks halfway. Then start the upgrade inside tmux, so a dropped connection doesn’t kill it:
tmux new -s upgradesudo do-release-upgradeIf SSH drops, log back in (or use ssh -p 1022 if port 22 refuses you) and run tmux attach -t upgrade. These are the
prompts I got, in order:
| Prompt | Answer | Why |
|---|---|---|
| Continue running under SSH? (spare sshd on port 1022) | y |
The spare SSH server is your way back in if the main one fails. |
| Third party sources disabled | Enter |
Expected. You re-enable the PHP repository in Step 11. |
| Do you want to start the upgrade? Continue [yN] Details [d] | d first |
Read the Remove list. It must not contain php7.4-*, php8.3-*, mysql-* or apache2. |
| Restart services during package upgrades without asking? | Yes | Otherwise every library update asks. |
Configuration file /etc/sudoers, /etc/sysctl.conf and so on |
N |
Keeps your version. A new sudoers or sshd_config can lock you out. |
/etc/default/grub modified: what do you want to do? |
Keep the local version | It holds the AWS boot settings. |
| Remove obsolete packages? | N |
The one that matters. See below. |
| System upgrade is complete. Restart required | y |
Reboots into the new release. |
On 22.04 to 24.04, the Remove list at the checkpoint had no PHP, MySQL or Apache package. Most “Remove (was auto
installed)” lines were libraries that 24.04 renamed, such as libssl3 to libssl3t64. MySQL stayed on 8.0.
Answer N to “Remove obsolete packages?”. The PHP repository is disabled during the upgrade, so its packages look obsolete to the upgrader. On my second hop that list had 147 packages, PHP included. Saying yes would have removed PHP from a dozen live sites.
If you see a “GRUB install devices” screen with a list of disks instead, stop and read it carefully. A wrong choice there can stop the server from booting. I didn’t get that screen.
On my host, the upgrade took about 17 minutes from the checkpoint to the reboot.
Step 11: Re-enable the PHP repository for 24.04
Changes an APT source, restarts PHP-FPM
After the reboot, check the release and services first:
lsb_release -ds; uname -rsystemctl is-active apache2 php7.4-fpm php8.3-fpm mysqlls /etc/apt/sources.list.d/Ubuntu 24.04.5 LTS7.0.0-1018-awsactiveactiveactiveactivesury-php.list.distUpgrade ubuntu.sourcesPHP-FPM keeps running the 22.04 builds for now, and my sites answered at this point. The upgrader renamed the
repository file to sury-php.list.distUpgrade. Move it aside and add the source for noble:
rel=noblesudo mv /etc/apt/sources.list.d/sury-php.list.* /root/old-apt/echo "deb [signed-by=/usr/share/keyrings/debsuryorg-archive-keyring.gpg] https://packages.sury.org/php/ $rel main" \ | sudo tee /etc/apt/sources.list.d/sury-php.listsudo apt-get update 2>&1 | grep -E '^(Err|E:|W:)' || echo 'no errors'sudo apt-get -s full-upgrade | grep -E '^(Inst|Remv)' | grep -E 'Remv|php|libapache2'Every PHP line should move from a debsuryorg22.04 build to a debsuryorg24.04 build of the same version. The only
Remv lines on my host were an old kernel. Install, keeping your php.ini and www.conf if asked:
sudo apt full-upgradedpkg -l | grep -E '^ii\s+php(7\.4|8\.3)' | grep -c '22\.04'The count should be 0, meaning no PHP package is left on a 22.04 build. The FPM binary is called php-fpm8.3, not
php8.3-fpm, if you want to print its version.
Part 3: Upgrade 24.04 to 26.04
Create a second AMI (pre-resolute-...) first as a 24.04 rollback point, and wait until it
is Available. Then take a fresh dump, check that the port 1022 security-group rule still
matches your IP, and install any pending updates. Step 7’s checks apply here too,
and do-release-upgrade -c should offer 26.04.1 LTS.
Step 12: Let MySQL 8.4 accept your sites’ logins
Changes the MySQL config, no restart
My first try at the second hop stopped by itself, with nothing changed:
Unable to upgrade MySQLThe following MySQL accounts use the mysql_native_passwordauthentication plugin, which is disabled by default in the version ofMySQL shipped with this release:root@127.0.0.1root@localhostThese accounts would be locked out after the upgrade....Restoring original system stateAbortingUbuntu 26.04 ships MySQL 8.4, which switches off the old mysql_native_password login method by default. Find the
accounts that still use it:
Read-only
sudo mysql --defaults-file=/etc/mysql/debian.cnf \ -e "SELECT user, host FROM mysql.user WHERE plugin = 'mysql_native_password';"The MySQL error log gives a hint that a site uses one of them. After each restart, mine logged 'mysql_native_password' is deprecated and will be removed in a future release as soon as a site connected.
Why Ubuntu’s note alone fails on 8.0
You have two fixes. The long-term one is to switch each account to caching_sha2_password with ALTER USER ... IDENTIFIED WITH caching_sha2_password BY ..., which also sets the password again. You can test that on 24.04 today,
site by site—restart MySQL during your test, because over TCP (127.0.0.1) without TLS, older PHP 7.4 connectors can
fail caching_sha2_password when MySQL’s in-memory cache is cold.
The quick fix in Ubuntu’s 26.04 release notes (opens in a new tab) turns the old method back on in MySQL’s config so nothing changes for the sites. I took the quick one—and hit a second wall when MySQL 8.0 rejected the line:
[ERROR] [MY-000067] [Server] unknown variable 'mysql_native_password=ON'.[ERROR] [MY-010119] [Server] AbortingIf MySQL 8.0 had restarted with mysql_native_password=ON in place, it would have refused to start.
How to fix it for both 8.0 and 8.4
The loose- prefix (opens in a new tab) tells MySQL to skip an option it
doesn’t know instead of aborting. MySQL 8.0 logs a warning and ignores it; MySQL 8.4 applies it after the upgrade. Check
first that [mysqld] is the only section in the file, or the last one, so the new line lands under it:
grep -n '^\s*\[' /etc/mysql/mysql.conf.d/mysqld.cnfsudo cp /etc/mysql/mysql.conf.d/mysqld.cnf ~/pre-upgrade/mysqld.cnf.backupecho 'loose-mysql_native_password = ON' | sudo tee -a /etc/mysql/mysql.conf.d/mysqld.cnfsudo mysqld --validate-config && echo 'CONFIG OK'--validate-config checks the file without starting MySQL. If it prints an [ERROR] instead of CONFIG OK, copy the
backup back before anything restarts MySQL. The upgrader accepted the loose- form and went on.
This is a stopgap: Ubuntu’s notes warn that the setting will stop working in a later release that ships MySQL 9.7.
Step 13: Run the second hop
Upgrades the OS, restarts everything
tmux new -s upgrade26sudo do-release-upgradeThe prompts are the same as in Step 10, with one more before the checkpoint:
Foreign Packages InstalledThe following unofficial packages are currently installed:libgd3...................Installed from: deb.sury.orglibpcre2-8-0.............Installed from: deb.sury.orgphp-common...............Installed from: deb.sury.orgIt is recommended to install supported versions from the Ubuntuarchive, and try the upgrade again.Do you want to continue the upgrade anyways?Continue [yN]Press y. Surý’s PHP builds depend on his versions of these three libraries, so swapping them for Ubuntu’s would
break PHP.
At the checkpoint, the Remove list includes mysql-server-8.0, mysql-client-8.0 and their -core packages.
That is a rename, not data loss: 26.04 ships them as mysql-server and mysql-client, which appear under Install.
Your data in /var/lib/mysql belongs to no package. The list also brings two 26.04 defaults, sudo-rs and
rust-coreutils. sudo-rs still reads your /etc/sudoers, and it asks for your password as
[sudo: authenticate] Password:.
At the config prompts, keeping your mysqld.cnf also keeps the loose- line. At “Remove obsolete packages?”, answer
N. On my host the list had 147 packages, including PHP. The hop took about 40 minutes from the checkpoint to the
reboot.
After the reboot:
lsb_release -dssystemctl is-active apache2 php7.4-fpm php8.3-fpm mysqlmysql --versionsudo grep -E '\[ERROR\]' /var/log/mysql/error.log | tail -5 | grep . || echo 'mysql: no errors'Ubuntu 26.04.1 LTSactiveactiveactiveactivemysql Ver 8.4.13-0ubuntu0.26.04.2 for Linux on x86_64 ((Ubuntu))mysql: no errorsMySQL converts its data dictionary from 8.0 during the upgrade. On my host it started cleanly on the first boot.
Step 14: Re-enable the PHP repository for 26.04
Changes an APT source, restarts PHP-FPM
Three small things change from Step 11: the upgrader renamed the file
to sury-php.list.disabled, rel is resolute, and Ubuntu 26.04 ships APT 3 with a new Summary: block. The signing
key survived both hops because Step 3 marked its package manual:
rel=resolutesudo mv /etc/apt/sources.list.d/sury-php.list.* /root/old-apt/echo "deb [signed-by=/usr/share/keyrings/debsuryorg-archive-keyring.gpg] https://packages.sury.org/php/ $rel main" \ | sudo tee /etc/apt/sources.list.d/sury-php.listsudo apt-get update 2>&1 | grep -E '^(Err|E:|W:)' || echo 'no errors'sudo apt-get -s full-upgrade | grep -E '^(Inst|Remv)' | grep -E 'Remv|php|libapache2|mysql'sudo apt -s full-upgrade 2>/dev/null | grep -A2 '^Summary'Summary: Upgrading: 37, Installing: 1, Removing: 0, Not Upgrading: 0The one new package on my host was libzip5, the 26.04 zip library that php7.4-zip and php8.3-zip now use. If you
see Removing: above 0, or a new PHP version, stop and read the list. Then install:
sudo apt full-upgradedpkg -l | grep -E '^ii\s+php(7\.4|8\.3)' | grep -c '24\.04'The count should be 0.
How do I know every site still works?
Read-only
Check from the server first. --resolve sends each request to this machine under the site’s real name, so a CDN or
DNS cache can’t hide a failure. Put your own site names in sites:
sites=(example.com www.example.org shop.example.net)for h in "${sites[@]}"; do printf '%s: ' "$h" curl -sk -o /dev/null -w '%{http_code}\n' --resolve "$h:443:127.0.0.1" "https://$h/"donesudo apache2ctl -M 2>/dev/null | grep -iE 'mpm|php|proxy_fcgi'systemctl show -p Id -p ActiveEnterTimestamp php7.4-fpm php8.3-fpmsystemctl --failed --no-pagerEach site should return 200, or 301 or 302 for a redirect. Apache should still show mpm_event_module and
proxy_fcgi_module with no php_module. The FPM start times should be after your last apt full-upgrade, which shows
they run the new builds.
A homepage that loads is not proof. In a browser, log in to two or three important sites, open a page that reads from the database, and submit a form. Watch the logs while you do it:
sudo tail -f /var/log/apache2/error.log /var/log/php7.4-fpm.log /var/log/php8.3-fpm.logLast, check that your backup still works against MySQL 8.4. mysqldump: Got errno 32 on write here only means head
stopped reading early:
sudo mysqldump --no-data --all-databases | head -3Clean up after the upgrade
- Remove the port 1022 rule from the security group.
- Preview
apt autoremovebefore you run it:sudo apt autoremove -s | grep -E '^Remv' | grep -E 'php|mysql|apache|debsury'should print nothing. On my host it then removed 124 old packages and freed 1.18 GB. - Keep both AMIs for a week or two. Then under Images → AMIs, choose Actions → Deregister AMI with Delete
associated snapshots ticked (or run
aws ec2 deregister-image --image-id <ami-id> --delete-associated-snapshots), or you keep paying for the snapshot storage. - Update launch templates and Auto Scaling groups that still use a
jammyAMI, or new instances will start on 22.04 and the AWS Health notice will come back. - Optionally move back to the regional mirror by putting
<region>.ec2.archive.ubuntu.comback in/etc/apt/sources.list.d/ubuntu.sources, then runsudo apt updateto confirm your region’s mirror servesresolute.
The OS is current now, but PHP 7.4 has had no security fixes from the PHP project since November 2022. Moving those sites to PHP 8.2 or newer is the next job, and it doesn’t depend on the OS.
What if I can’t upgrade before May 31, 2027?
Your Ubuntu 22.04 EC2 instances keep running after May 31, 2027. They stop getting standard security fixes. The AWS notice gives the option for this case: convert the instance to Ubuntu Pro 22.04 in place with AWS License Manager (opens in a new tab), which extends security maintenance to May 2032. Nothing gets rebuilt, but you pay for the licence.
What I’d do differently
I’d do all of Part 1 before the first apt full-upgrade, not in response to it: protect the packages, remove the
generic and Apache PHP packages, then update. I’d also fix the mirror and snapd before running the upgrader once. On a
server with more at stake, I’d rehearse both hops on an instance launched from the AMI. I skipped that and relied on
the AMI as the rollback.
Sources
- AWS, Ubuntu 22.04 LTS end of standard support FAQs (opens in a new tab), linked from the AWS Health notice.
- AWS, converting Linux instances to Ubuntu Pro with License Manager (opens in a new tab).
- Ubuntu, 26.04 release notes: summary for LTS users, MySQL (opens in a new tab).
- MySQL, command-line option modifiers, including
loose-(opens in a new tab). - AWS, Create an Amazon EBS-backed AMI (opens in a new tab) and Replace the root volume (opens in a new tab).
- AWS, EC2 Serial Console (opens in a new tab).
- Ondřej Surý, PHP packages for Debian and Ubuntu (opens in a new tab).