· 3 min read
Upgrading Ubuntu 20.04 → 24.04 and PHP 7.4 → PHP 8.3 (Apache + WordPress)
This guide walks through a real-world, production-safe upgrade path: Ubuntu 20.04 → 22.04 → 24.04 and PHP 7.4 → PHP 8.3 (Apache + WordPress)
Upgrading Ubuntu 20.04 → 24.04 and PHP 7.4 → PHP 8.3 (Apache + WordPress)
This guide walks through a real-world, production-safe upgrade path:
- Ubuntu 20.04 → 22.04 → 24.04
- PHP 7.4 → 8.3
- Apache using mpm_event + PHP-FPM
- WordPress-safe PHP extensions
- Avoids Ubuntu Pro / ESM blockers
0. Pre-flight checklist (DO NOT SKIP)
lsb_release -a
php -v
apachectl -M | egrep 'mpm|php'Backups:
- VM snapshot (or image)
/etc/var/www- Databases
1. Clean up old PHP 7.4 packages (critical)
Leftover PHP 7.4 packages will block upgrades.
sudo apt purge -y \
php7.4\* libapache2-mod-php7.4
sudo apt autoremove -y
sudo apt autocleanConfirm nothing 7.4 remains:
apt list --installed | grep php7.4 || echo "PHP 7.4 removed"2. Fully update Ubuntu 20.04 (ignore Ubuntu Pro warnings)
You do not need Ubuntu Pro to upgrade releases.
sudo apt update
sudo apt full-upgrade -y
sudo rebootIf you see “security updates require Ubuntu Pro”, that’s fine — they are not blockers for release upgrades.
3. Upgrade Ubuntu 20.04 → 22.04
sudo do-release-upgrade- Choose keep local version when prompted for everything except Chrony
- Reboot when finished
Verify:
lsb_release -a4. Upgrade Ubuntu 22.04 → 24.04
sudo apt update
sudo apt full-upgrade -y
sudo do-release-upgrade
sudo rebootVerify:
lsb_release -a
# Should show 24.04.x5. Install PHP 8.3 (WordPress-safe stack)
Ubuntu 24.04 ships PHP 8.3 natively.
sudo apt install -y \
php8.3 php8.3-fpm php8.3-cli php8.3-common \
php8.3-mysql php8.3-curl php8.3-gd php8.3-imagick \
php8.3-intl php8.3-mbstring php8.3-xml php8.3-zip \
php8.3-bcmath php8.3-soap php8.3-opcacheVerify:
php -v6. Switch Apache to mpm_event + PHP-FPM (recommended)
Disable prefork + mod_php:
sudo a2dismod php7.4 php8.3 mpm_preforkEnable event + proxy modules:
sudo a2enmod mpm_event proxy_fcgi setenvif
sudo a2enconf php8.3-fpmRestart:
sudo systemctl restart php8.3-fpm
sudo systemctl restart apache2Confirm:
apachectl -M | egrep 'mpm|fcgi'You should see:
mpm_eventproxy_fcgi
7. Set PHP upload limits (CLI + FPM)
Create a single override file.
PHP-FPM (used by Apache / WordPress)
sudo tee /etc/php/8.3/fpm/conf.d/99-uploads.ini > /dev/null <<'EOF'
upload_max_filesize = 128M
post_max_size = 128M
memory_limit = 256M
max_execution_time = 300
EOF
sudo systemctl restart php8.3-fpm
sudo systemctl reload apache2PHP CLI (optional but recommended)
sudo tee /etc/php/8.3/cli/conf.d/99-uploads.ini > /dev/null <<'EOF'
upload_max_filesize = 128M
post_max_size = 128M
memory_limit = 256M
max_execution_time = 300
EOFVerify FPM:
sudo php-fpm8.3 -i | egrep 'upload_max_filesize|post_max_size|memory_limit|max_execution_time'8. Security hardening (quick wins)
Disable CGI if not needed:
sudo a2disconf serve-cgi-bin
sudo systemctl reload apache2Blocking xmlrpc.php and /server-status errors in logs is expected and healthy for WordPress.
9. Final verification checklist
php -v
apachectl -M | egrep 'mpm|php|fcgi'
systemctl status php8.3-fpm --no-pagerWordPress:
- Media uploads work
- Plugins update correctly
- No raw PHP output
Notes on PHP versions
- PHP 8.3 is the correct, stable target for Ubuntu 24.04
- PHP 8.4 exists but is not recommended yet for WordPress production
- Stick to 8.3 until WordPress core officially endorses 8.4
TL;DR
✔ Purge PHP 7.4 ✔ apt full-upgrade before every release jump ✔ Upgrade 20 → 22 → 24, never skip ✔ Use mpm_event + PHP-FPM ✔ Set limits in FPM, not just CLI