How to Upgrade PHP 8.2 to PHP 8.3 on Ubuntu 24.04
PHP is one of the most widely used server-side scripting languages for creating dynamic websites and web applications. Each release of PHP introduces performance improvements, language enhancements, and new modern capabilities. PHP 8.3 builds on the foundation of PHP 8.2 by adding features like explicit typing for class constants, readonly classes, deep cloning for readonly properties, and expanded function support.
This guide demonstrates how to upgrade PHP 8.2 to PHP 8.3 on Ubuntu 24.04. You will learn how to update the PHP repository sources, install PHP 8.3, configure PHP-FPM, and add common PHP extensions for use with Apache or Nginx web servers.
Prerequisites
Before you start, make sure the following requirements are met:
- You have access to an Ubuntu 24.04 instance where PHP 8.2 is already installed.
- You are logged in as a non-root user with
sudoprivileges to install and manage software packages.
Add PHP PPA Repository
Ubuntu 24.04’s default APT repositories only include a limited set of PHP versions. To access newer versions such as PHP 8.3, you can add an external PHP PPA maintained by Ondřej Surý — a trusted source widely used within the PHP community. Follow these steps to install and enable the PPA repository.
Step 1: Update the Package Index
$ sudo apt update
Step 2: Install Required Dependencies
$ sudo apt install apt-transport-https ca-certificates software-properties-common -y
Step 3: Add the PHP PPA Repository
$ sudo add-apt-repository -y ppa:ondrej/php
Step 4: Update the Package Index Again
$ sudo apt update
List Installed PHP 8.2 Modules
Before performing the upgrade, it’s helpful to review which PHP 8.2 modules are currently installed. This will allow you to reinstall equivalent modules for PHP 8.3 afterward. Follow the steps below to view all active PHP 8.2 modules on your system.
Step 1: Display Active PHP Modules
$ php -m
Step 2: List Installed PHP 8.2 Packages
Run the following command to display all PHP 8.2-related packages and save the list to a text file for reference.
$ dpkg -l | grep php8.2 | tee packages.txt
Example output:
php8.2 server-side, HTML-embedded scripting language (metapackage)
php8.2-bz2 bzip2 module for PHP
php8.2-cli command-line interpreter for the PHP scripting language
php8.2-common documentation, examples and common module for PHP
php8.2-curl CURL module for PHP
php8.2-fpm server-side, HTML-embedded scripting language (FPM-CGI binary)
php8.2-intl Internationalisation module for PHP
php8.2-mbstring MBSTRING module for PHP
php8.2-opcache Zend OpCache module for PHP
php8.2-readline readline module for PHP
Install PHP 8.3
After adding the PHP PPA, you can now install PHP 8.3 and its dependencies. PHP requires supporting libraries and web server integration tools to function properly. Follow the steps below to install PHP 8.3.
Step 1: Install PHP 8.3
$ sudo apt install -y php8.3
Step 2: Verify the PHP Version
$ php8.3 -v
Expected output:
PHP 8.3.19 (cli) (built: Mar 13 2025 17:44:40) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.19, Copyright (c) Zend Technologies
with Zend OPcache v8.3.19, Copyright (c), by Zend Technologies
Step 3: Check Installed PHP Versions
$ ls /etc/php
You should now see both PHP 8.2 and PHP 8.3 directories, confirming the new version was successfully installed.
8.2 8.3
Optional: Uninstall PHP 8.2
Removing PHP 8.2 helps ensure PHP 8.3 becomes the default version on your system. It also reclaims disk space and avoids potential PHP-FPM conflicts on the default port 9000.
Step 1: Remove the Base PHP 8.2 Package
Use the following command to uninstall the main PHP 8.2 package using APT.
$ sudo apt remove -y php8.2
Step 2: Purge All PHP 8.2 Packages
Completely remove PHP 8.2-related extensions, configuration files, and dependencies.
$ sudo apt purge php8.2*
Step 3: Remove Unused Dependencies
Clean up residual dependencies no longer needed by PHP 8.2.
$ sudo apt autoremove -y
Step 4: Verify the Active PHP Version
Run the following command to confirm that PHP 8.3 is now the active version on your system.
$ php -v
Example output:
PHP 8.3.20 (cli) (built: Apr 10 2025 21:33:50) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.20, Copyright (c) Zend Technologies
with Zend OPcache v8.3.20, Copyright (c), by Zend Technologies
Conclusion
You have successfully upgraded from PHP 8.2 to PHP 8.3 on Ubuntu 24.04. In this process, you installed core PHP extensions, configured PHP-FPM in your web server, and removed PHP 8.2 to ensure PHP 8.3 remains the default version. It’s also possible to maintain multiple PHP versions on the same machine and switch between them as needed for different projects. For advanced configurations and detailed documentation, refer to the official PHP documentation.


