PHP 8.4 is the current stable release on the 8.x branch, introducing property hooks, asymmetric visibility, new array utility functions, and a proper HTML5 DOM parser. It also carries active security support and measurable performance improvements over 8.2 and 8.3. This covers the exact steps to upgrade from any earlier PHP version to 8.4 on Ubuntu using the Ondrej Sury PPA — the standard third-party PHP repository for Ubuntu that provides all PHP versions ahead of official Ubuntu package support.
What’s new in PHP 8.4
- Property hooks —
getandsetlogic can now be defined directly on class properties without writing separate getter/setter methods. This is the most impactful syntax addition in 8.4. - Asymmetric visibility — properties can be declared
public private(set), making them publicly readable but only writable from within the class. Replaces common readonly workarounds. - New array functions —
array_find(),array_find_key(),array_any(), andarray_all()reduce the need for verbosearray_filter/array_mapcombinations. - New HTML5 DOM parser —
Dom\Documentreplaces the older libxml2-based parser with a Lexbor-based HTML5 parser that handles modern HTML markup correctly. #[\Deprecated]attribute — code can mark its own APIs as deprecated using a native PHP attribute rather than relying on docblocks ortrigger_error().- JIT improvements — reduced compilation overhead and more stable JIT output for CPU-intensive and long-running CLI workloads.
Prerequisites
- Ubuntu 20.04, 22.04, or 24.04 (this process works on all current LTS releases)
- SSH or terminal access with
sudoprivileges - A backup of your application code and database — extension incompatibility is the most common failure mode on the first upgrade attempt
- A staging environment to test the upgrade before applying to production if available — see how to set up a WordPress staging site
Add the Ondrej Sury PPA
The Sury PPA is the standard PHP package source for Ubuntu — it provides all PHP versions from 7.4 through 8.5, updated alongside official PHP releases. Ubuntu’s default apt repositories lag behind official PHP releases, particularly for non-LTS PHP versions, so the PPA is required for PHP 8.4 on Ubuntu 20.04, 22.04, and 24.04.
sudo apt update
sudo apt install software-properties-common -y
sudo add-apt-repository ppa:ondrej/php
sudo apt update
Install PHP 8.4 and required extensions
Install the base package and the extensions your application needs. The list below covers a typical WordPress or PHP application stack:
sudo apt install php8.4 \
php8.4-common \
php8.4-cli \
php8.4-fpm \
php8.4-mysql \
php8.4-curl \
php8.4-opcache \
php8.4-mbstring \
php8.4-xml \
php8.4-zip \
php8.4-readline
Additional extensions commonly needed: php8.4-gd for image processing, php8.4-intl for internationalization, php8.4-redis for Redis object caching, php8.4-imagick for ImageMagick integration. Install only what your application explicitly requires — unused extensions add overhead to every PHP process.
Switch to PHP 8.4 on Apache
If you’re running Apache with mod_php (the standard single-server setup), disable the current PHP module and enable the 8.4 module:
sudo a2dismod php8.2 # replace 8.2 with whichever version is currently active
sudo a2enmod php8.4
sudo service apache2 restart
The correct Apache mod_php package name is libapache2-mod-php8.4 — install it if the a2enmod php8.4 step reports the module as unavailable:
sudo apt install libapache2-mod-php8.4
If you’re using Apache with PHP-FPM (via proxy_fcgi), enable the required Apache modules and update the configuration to point to the PHP 8.4 FPM socket:
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php8.4-fpm
sudo service apache2 restart
sudo systemctl restart php8.4-fpm
Switch to PHP 8.4 on Nginx
Nginx uses PHP-FPM rather than a built-in PHP module. Update your site configuration to point to the PHP 8.4 FPM socket:
# In /etc/nginx/sites-available/your-site, update the fastcgi_pass line:
# fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
sudo systemctl restart php8.4-fpm
sudo systemctl restart nginx
Update the CLI PHP version
The web server PHP version and the CLI PHP version are managed independently. If php -v in the terminal still shows an older version after the web server switch, update the CLI default:
sudo update-alternatives --config php
Select the entry showing /usr/bin/php8.4. If build scripts use phpize or php-config, update those as well:
sudo update-alternatives --config phpize
sudo update-alternatives --config php-config
Verify the upgrade
php -v
Expected output:
PHP 8.4.x (cli) (built: ...)
...
Additional checks:
- Load a page on your site and confirm it renders without PHP errors or blank output
- Create a temporary
phpinfo()file and verify the PHP version and loaded extensions match what you installed — delete the file immediately after checking - Review PHP-FPM and web server error logs for deprecation notices or fatal errors from your application code
Post-upgrade checks
- Review php.ini for settings that may have changed defaults in 8.4 — particularly
error_reporting,display_errors, and JIT configuration (opcache.jit) - Address deprecation notices — PHP 8.4 deprecates several functions available in 8.3; these appear as notices in error logs, not fatal errors, but indicate code to fix before the PHP 9 cycle
- Confirm all extensions loaded with
php -m | grep <extension>for any extension your application explicitly depends on - Remove the old PHP version once the upgrade has run stably for 48+ hours:
sudo apt purge php8.2*(adjust the version number)
For WordPress sites, PHP 8.4 compatibility depends on installed plugins and the active theme — a plugin using a deprecated or removed function is the most common source of failures. Testing on staging before upgrading production eliminates most surprises. For the monthly PHP version check and update routine that keeps a WordPress server current and secure, see the WordPress maintenance guide. PHP version currency is also one of the core items in the WordPress security practices checklist — older PHP branches stop receiving security patches at end-of-life.
Troubleshooting
| Problem | Solution |
|---|---|
| Extension not found or not loading | Install via sudo apt install php8.4-<extension>. Confirm loaded with php -m | grep <extension> |
| Web server still shows old PHP version | Disable old mod, enable php8.4, restart web server. For CLI mismatch, run sudo update-alternatives --config php |
| Nginx PHP-FPM socket permission errors | Check listen.owner and listen.group in /etc/php/8.4/fpm/pool.d/www.conf — must match the Nginx user (typically www-data) |
| WordPress blank page after upgrade | Set define('WP_DEBUG', true); in wp-config.php to surface PHP errors. A plugin using a deprecated or removed function is the most common cause — deactivate plugins one by one to isolate |
| PHP-FPM service fails to start | Check sudo journalctl -u php8.4-fpm for the error. A missing extension or malformed php.ini entry is the usual cause |
Once PHP 8.4 is stable on your server, the PHP 8.5 upgrade guide covers the next version’s changes and the same upgrade process when you’re ready to move forward.


