PHP 8.3 introduces typed class constants for stricter compile-time checks, the json_validate() function for efficient JSON validation without decoding, and deep-cloning support for readonly properties in __clone methods. These additions reduce boilerplate code and improve type safety in object-oriented applications. To install PHP 8.3 on Ubuntu 22.04 or 24.04, use the Ondrej Sury PHP PPA, which provides co-installable PHP versions with regular security updates.
The steps below walk through adding the Sury PPA, installing PHP 8.3 with Apache or Nginx, configuring PHP-FPM for production workloads, and managing extensions. After completing these steps, you will have PHP 8.3 configured and ready to power WordPress, Laravel, or any application that benefits from typed constants and the improved JSON validation.
Add the PHP 8.3 PPA on Ubuntu
Update System Packages
Before adding external repositories, synchronize your package index and upgrade installed packages to ensure compatibility:
sudo apt update
sudo apt upgrade
If you do not have
sudoprivileges or need to configure a sudo user, refer to how to add a user to sudoers on Ubuntu.
Install Prerequisites for PPA Management
Next, the software-properties-common package provides the add-apt-repository command needed to add PPAs. Install it along with other common utilities:
sudo apt install software-properties-common ca-certificates lsb-release -y
The
apt-transport-httpspackage is no longer needed on Ubuntu 22.04 and newer. HTTPS support is now built into APT directly, so you can skip any guides that still list it as a prerequisite.
Add the Ondrej Sury PHP PPA
The Ondrej Sury PPA provides co-installable PHP versions from 5.6 through 8.5, allowing you to run multiple PHP versions side by side. Add the repository with:
sudo add-apt-repository ppa:ondrej/php -y
After adding the PPA, refresh the package index to make the new packages available:
sudo apt update
Then, confirm PHP 8.3 is available from the PPA:
apt-cache policy php8.3
Expected output showing the Sury PPA as the package source:
php8.3:
Installed: (none)
Candidate: 8.3.30-1+ubuntu24.04.1+deb.sury.org+1
Version table:
8.3.30-1+ubuntu24.04.1+deb.sury.org+1 500
500 https://ppa.launchpadcontent.net/ondrej/php/ubuntu noble/main amd64 Packages
8.3.6-0ubuntu0.24.04.6 500
500 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Packages
This guide covers Ubuntu 22.04 LTS and 24.04 LTS. The version numbers and codename in the output above will match your release—replace
noblewithjammyfor 22.04. On 24.04, you will see both the PPA version and the default Ubuntu repository version; the PPA version typically has a higher version number. At the time of writing, the PPA does not yet publish packages for Ubuntu 26.04 LTS (Resolute), so 26.04 users should use the default PHP 8.4 packages or wait for PPA support.
Install PHP 8.3 on Ubuntu
At this point, select the installation method that matches your web server configuration. Apache users can choose between mod_php (simpler setup) or PHP-FPM (better resource management). In contrast, Nginx requires PHP-FPM exclusively.
Compare PHP Installation Methods
| Method | Web Server | Process Model | Best For |
|---|---|---|---|
| Apache mod_php | Apache only | Embedded in worker | Development environments; simplest setup |
| Apache + PHP-FPM | Apache | Separate pool managers | Production sites; better memory management |
| Nginx + PHP-FPM | Nginx | Separate pool managers | High-traffic production; static file performance |
For production environments, PHP-FPM is recommended because it runs as a separate process pool, allowing finer control over memory usage, timeouts, and process lifecycle. Therefore, use mod_php only for development or low-traffic sites where simplicity matters more than resource efficiency.
Option 1: Install PHP 8.3 with Apache mod_php
The mod_php approach loads PHP as an Apache module, making it suitable for development environments or smaller sites where simplicity matters more than process isolation. To begin, install the packages:
sudo apt install php8.3 libapache2-mod-php8.3
Afterward, restart Apache to activate the PHP module:
sudo systemctl restart apache2
Then, verify PHP is loaded:
php --version
You should see expected output similar to:
PHP 8.3.30 (cli) (built: Jan 18 2026 14:22:06) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.30, Copyright (c) Zend Technologies
with Zend OPcache v8.3.30, Copyright (c), by Zend Technologies
Option 2: Install PHP 8.3 with Apache and PHP-FPM
PHP-FPM runs PHP in a separate process pool, providing better memory management and the ability to run different PHP versions for different virtual hosts. To set this up, install the required packages:
sudo apt install php8.3-fpm libapache2-mod-fcgid
If mod_php is installed from a previous configuration, disable it before enabling PHP-FPM:
sudo a2dismod php8.3
Once installed, enable the required Apache modules and PHP-FPM configuration:
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php8.3-fpm
Now, enable and start PHP-FPM, then restart Apache to apply changes:
sudo systemctl enable php8.3-fpm --now
sudo systemctl restart apache2
Finally, confirm PHP-FPM is running:
sudo systemctl status php8.3-fpm
Expected output confirming active status:
● php8.3-fpm.service - The PHP 8.3 FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php8.3-fpm.service; enabled; preset: enabled)
Active: active (running) since [date and time]
Main PID: [pid] (php-fpm8.3)
Tasks: [number]
Memory: [size]
CPU: [time]
CGroup: /system.slice/php8.3-fpm.service
Option 3: Install PHP 8.3 with Nginx and PHP-FPM
Nginx processes PHP through FastCGI, making PHP-FPM the only option. Therefore, install the required packages:
sudo apt install php8.3 php8.3-fpm php8.3-cli
Next, enable and start PHP-FPM:
sudo systemctl enable php8.3-fpm --now
Then, verify PHP-FPM status:
sudo systemctl status php8.3-fpm
Expected output confirming active status:
● php8.3-fpm.service - The PHP 8.3 FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php8.3-fpm.service; enabled; preset: enabled)
Active: active (running) since [date and time]
Configure Nginx Server Block for PHP-FPM
Now, add this location block to your Nginx server configuration to route PHP requests through PHP-FPM 8.3:
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
}
Before applying changes, test the configuration syntax:
sudo nginx -t
Expected output for valid configuration:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
Once validated, apply the configuration:
sudo systemctl restart nginx
Verify PHP 8.3 Installation
Regardless of which method you chose, confirm PHP 8.3 installed correctly:
php --version
You should see expected output similar to:
PHP 8.3.30 (cli) (built: Jan 18 2026 14:22:06) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.30, Copyright (c) Zend Technologies
with Zend OPcache v8.3.30, Copyright (c), by Zend Technologies
Install PHP 8.3 Extensions on Ubuntu
Install Common PHP 8.3 Extensions
Most web applications require extensions beyond the base PHP installation. Accordingly, install a comprehensive set covering WordPress, Laravel, and general PHP development needs:
sudo apt install php8.3-{curl,mysql,gd,opcache,zip,intl,common,bcmath,imagick,readline,memcached,redis,mbstring,apcu,xml,soap}
Several extensions are bundled with PHP 8.3 core packages and do not require separate installation. The
php8.3-commonpackage includes tokenizer, fileinfo, openssl, PDO, pdo_mysql, filter, hash, session, and ctype. Thephp8.3-xmlpackage provides DOM, SimpleXML, XMLReader, and XMLWriter. JSON support is built into PHP core since 8.0, so no separatephp8.3-jsonpackage exists. Thephp8.3-mysqlpackage includes both MySQLi and MySQLnd drivers for connecting to MySQL and MariaDB databases.
After installation, restart your PHP handler to load the new extensions. For PHP-FPM users:
sudo systemctl restart php8.3-fpm
If you installed PHP 8.3 with Apache mod_php instead of PHP-FPM, restart Apache to load the new extensions:
sudo systemctl restart apache2
Subsequently, verify the core extensions are loaded:
php8.3 -m | grep -E 'curl|mysqli|gd|mbstring|xml'
Expected output showing the extensions are active:
curl gd libxml mbstring mysqli xml xmlreader xmlwriter
PHP 8.3 Extension Reference
For reference, the extensions installed above provide these capabilities:
| Package | Provides | Use Case |
|---|---|---|
| php8.3-curl | cURL HTTP client | API requests and remote file operations |
| php8.3-mysql | MySQLi and MySQLnd | MariaDB and MySQL database connectivity |
| php8.3-gd | GD graphics library | Image creation and manipulation (thumbnails, watermarks, captchas) |
| php8.3-opcache | Zend OPcache | Bytecode caching to reduce PHP compilation overhead |
| php8.3-zip | ZIP archive support | Archive creation and extraction |
| php8.3-intl | Internationalization | Number formatting, date handling, and collation |
| php8.3-bcmath | BCMath arbitrary precision | Financial calculations |
| php8.3-imagick | ImageMagick bindings | Advanced image processing |
| php8.3-memcached | Memcached client | Distributed caching backend for session storage |
| php8.3-redis | Redis client | Session storage and object caching |
| php8.3-mbstring | Multibyte string handling | UTF-8 and international text processing |
| php8.3-apcu | APCu user cache | In-memory application data cache |
| php8.3-xml | DOM, SimpleXML, XSL | XML parsing and processing |
| php8.3-soap | SOAP protocol | SOAP web services client and server functionality |
Search Available PHP 8.3 Extensions
To explore additional options, you can list all available PHP 8.3 modules from the repository:
apt search php8.3-
Sample output showing available extensions:
Sorting... Full Text Search... php8.3-amqp/noble 2.x.x amd64 AMQP extension for PHP php8.3-apcu/noble 5.x.x amd64 APC User Cache for PHP php8.3-bcmath/noble 8.3.x amd64 Bcmath module for PHP [additional packages...]
List Loaded PHP 8.3 Modules
Alternatively, display all currently active PHP modules:
php8.3 -m
Sample output showing loaded modules:
[PHP Modules] calendar Core ctype curl date dom exif fileinfo filter gd hash iconv intl json libxml mbstring mysqli openssl pcre PDO pdo_mysql Phar readline Reflection session SimpleXML sockets sodium SPL standard tokenizer xml Zend OPcache zip zlib [Zend Modules] Zend OPcache
Install PHP 8.3 Development Tools
Additionally, for code coverage analysis and extension development, install these packages:
sudo apt install php8.3-xdebug php8.3-pcov php8.3-dev
The
php8.3-xdebugextension significantly impacts performance. Install it only on development systems, not production servers. For production-safe code coverage, usephp8.3-pcovinstead.
Specifically, the php8.3-pcov package provides lightweight code coverage reporting compatible with PHPUnit, while php8.3-dev includes headers and tools for compiling PHP extensions from source. For managing PHP project dependencies, also consider installing Composer.
Compare PHP Versions on Ubuntu
Ubuntu repositories and the Sury PPA provide different PHP versions depending on the release. The table below shows the default PHP version included with each Ubuntu LTS release and how PHP 8.3 is available.
| Ubuntu Release | Default PHP Version | PHP 8.3 Source |
|---|---|---|
| 22.04 LTS (Jammy) | 8.1.x | Sury PPA required |
| 24.04 LTS (Noble) | 8.3.x | Default repos (8.3.6) or Sury PPA for latest point releases (8.3.30) |
| 26.04 LTS (Resolute) | 8.4.x | Not yet available from Sury PPA |
Compare PHP Versions Available for Ubuntu
Beyond the default versions listed above, the Sury PPA provides multiple PHP releases targeting distinct use cases. The comparison below outlines how PHP 8.3 fits alongside other available versions and their support timelines.
| PHP Version | Primary Focus | Support Status | Best For | Trade-offs |
|---|---|---|---|---|
| PHP (Distro Default) | Stability with Ubuntu security team maintenance | Matches Ubuntu release lifecycle | Production servers prioritizing official Ubuntu updates and minimal external dependencies | Version varies by release (8.1 on 22.04, 8.3 on 24.04) |
| PHP 8.5 | URI extension, pipe operator, clone with properties | Active support through December 2027; security through December 2029 | Modern applications using functional programming patterns, URL parsing, and immutable object patterns | Requires Sury PPA; newest release |
| PHP 8.4 | Property hooks, asymmetric visibility, #[\Deprecated] attribute | Active support through December 2026; security through December 2028 | Production applications using modern OOP patterns, type-safe APIs, and improved deprecation handling | Requires Sury PPA; community-maintained updates |
| PHP 8.3 | Typed class constants, json_validate(), readonly property cloning | Security-only through December 2027 (active support ended) | WordPress 6.x, Laravel 11, Drupal 10 sites needing stable features with long security support | Default on 24.04; security patches only on Sury PPA |
| PHP 8.2 | Readonly classes, DNF types, standalone null/false/true types | Security-only through December 2026 (active support ended) | Legacy applications requiring PHP 8.2 compatibility | No new features; security patches only |
PHP 8.3 balances proven stability with broad framework compatibility across WordPress 6.x, Laravel 11, and Drupal 10, receiving security-only updates through December 2027. While PHP 8.5 introduces the pipe operator and URI extension, PHP 8.3 offers a more established codebase with extensive community testing. If your application runs well on the distro default PHP and you prefer official Ubuntu security team maintenance, that version remains a solid alternative.
Configure PHP 8.3 Settings on Ubuntu
Locate PHP Configuration Files
PHP 8.3 maintains separate configuration files for CLI (command line) and PHP-FPM (web server). Consequently, to find the active configuration file for each environment, run:
php8.3 --ini | head -3
Expected output showing CLI configuration paths:
Configuration File (php.ini) Path: /etc/php/8.3/cli Loaded Configuration File: /etc/php/8.3/cli/php.ini Scan for additional .ini files in: /etc/php/8.3/cli/conf.d
For PHP-FPM (used by Apache with PHP-FPM or Nginx), the configuration file is at /etc/php/8.3/fpm/php.ini instead. Notably, changes to CLI settings do not affect web applications, and vice versa.
Adjust Common PHP Settings
To modify settings for web applications using PHP-FPM, edit the FPM configuration file:
sudo nano /etc/php/8.3/fpm/php.ini
Common settings to adjust based on your application requirements:
; Maximum upload file size (default: 2M)
upload_max_filesize = 64M
; Maximum POST data size (must be >= upload_max_filesize)
post_max_size = 64M
; Maximum memory per script (default: 128M)
memory_limit = 256M
; Maximum script execution time in seconds (default: 30)
max_execution_time = 120
; Maximum input variables (default: 1000)
max_input_vars = 3000
For production servers, also consider setting
display_errors = Offto prevent exposing sensitive information,expose_php = Offto hide the PHP version in HTTP headers, and enabling OPcache with appropriate settings for your workload.
After making changes, restart PHP-FPM to apply them:
sudo systemctl restart php8.3-fpm
Then verify the FPM configuration reflects the new settings:
grep -E 'upload_max_filesize|post_max_size|memory_limit' /etc/php/8.3/fpm/php.ini | grep -v '^;'
Expected output confirming the new values:
upload_max_filesize = 64M post_max_size = 64M memory_limit = 256M
PHP maintains separate configuration files for CLI and FPM. The
php8.3 -icommand shows CLI settings from/etc/php/8.3/cli/php.ini, not FPM settings. To verify web application settings, check/etc/php/8.3/fpm/php.inidirectly or create aphpinfo()test page. Changes to one configuration file do not affect the other.
Run Multiple PHP Versions on Ubuntu
How Multiple PHP Versions Work Together
The Sury PPA packages each PHP version independently, so installing PHP 8.3 does not remove existing PHP installations. As a result, you can run PHP 8.1, 8.2, and 8.3 simultaneously, assigning different versions to different virtual hosts or projects.
Switch Command Line PHP Version
To manage CLI versions, use update-alternatives to configure which PHP version responds to the php command:
sudo update-alternatives --config php
You will then see interactive output showing available versions:
There are 2 choices for the alternative php (providing /usr/bin/php). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/php8.3 83 auto mode 1 /usr/bin/php8.2 82 manual mode 2 /usr/bin/php8.3 83 manual mode Press <enter> to keep the current choice[*], or type selection number:
Enter the number corresponding to your preferred version. Alternatively, to set PHP 8.3 directly without the interactive prompt:
sudo update-alternatives --set php /usr/bin/php8.3
Switch Apache PHP Version
Similarly, when using mod_php with Apache, first disable the current PHP module and then enable the desired version:
sudo a2dismod php8.2
sudo a2enmod php8.3
sudo systemctl restart apache2
Switch Apache PHP-FPM Version
For Apache with PHP-FPM, instead swap the configuration files:
sudo a2disconf php8.2-fpm
sudo a2enconf php8.3-fpm
sudo systemctl restart apache2
Switch Nginx PHP-FPM Version
Likewise, for Nginx, update the fastcgi_pass directive in your server block to point to the desired PHP-FPM socket:
# For PHP 8.2
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
# For PHP 8.3
fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
After making changes, test and reload Nginx:
sudo nginx -t && sudo systemctl reload nginx
Remove PHP 8.3 from Ubuntu
Uninstall PHP 8.3 Packages
To remove PHP 8.3 and its extensions while preserving other PHP versions, run:
sudo apt remove php8.3*
APT will then display the packages to be removed before proceeding:
The following packages will be removed: libapache2-mod-php8.3 php8.3 php8.3-cli php8.3-common php8.3-curl php8.3-fpm php8.3-gd php8.3-mbstring php8.3-mysql php8.3-opcache php8.3-xml php8.3-zip [additional packages...]
Alternatively, to remove configuration files as well, use purge instead of remove:
The
purgecommand permanently deletes PHP configuration files in/etc/php/8.3/. If you have customizedphp.inior pool configurations, back them up before running this command.
sudo apt purge php8.3*
Finally, clean up any orphaned dependencies that were installed only for PHP 8.3:
sudo apt autoremove
Remove the Ondrej Sury PPA
If you no longer need packages from the Sury PPA, remove the configuration:
sudo add-apt-repository --remove ppa:ondrej/php -y
sudo apt update
After removing the PPA, verify PHP 8.3 is no longer available:
apt-cache policy php8.3
Expected output showing no installation candidate (on Ubuntu 22.04):
php8.3: Installed: (none) Candidate: (none) Version table:
On Ubuntu 24.04, PHP 8.3 remains available from the default repositories even after removing the PPA. The output will show the Ubuntu repository version instead of “(none)”.
Troubleshoot PHP 8.3 Installation Issues on Ubuntu
PHP-FPM Socket Not Found
If Nginx returns a 502 Bad Gateway error, first check the Nginx error log for socket connection failures:
sudo tail -5 /var/log/nginx/error.log
A common error indicating PHP-FPM is not running looks like this:
connect() to unix:/var/run/php/php8.3-fpm.sock failed (2: No such file or directory) while connecting to upstream
Next, verify the PHP-FPM socket exists:
ls -la /var/run/php/php8.3-fpm.sock
Expected output when the socket exists:
srw-rw---- 1 www-data www-data 0 [date] [time] /var/run/php/php8.3-fpm.sock
Conversely, if the socket is missing, check PHP-FPM status and then start the service:
sudo systemctl status php8.3-fpm
sudo systemctl enable php8.3-fpm --now
Afterward, verify the socket now exists and test the configuration:
ls -la /var/run/php/php8.3-fpm.sock
sudo nginx -t && sudo systemctl reload nginx
Wrong PHP Version Active
Occasionally, if php --version shows an older PHP version after installing 8.3, you need to update the alternatives system:
sudo update-alternatives --set php /usr/bin/php8.3
Subsequently, verify the change took effect:
php --version
Expected output confirming PHP 8.3 is now the default:
PHP 8.3.30 (cli) (built: Jan 18 2026 14:22:06) (NTS) Copyright (c) The PHP Group Zend Engine v4.3.30, Copyright (c) Zend Technologies
Extension Not Loading After Installation
If an extension appears installed but is not loading, first confirm it is installed:
dpkg -l | grep php8.3-curl
Expected output showing the package is installed:
ii php8.3-curl 8.3.30-1+ubuntu24.04.1+deb.sury.org+1 amd64 CURL module for PHP
Then check if the extension is enabled in the PHP configuration:
php8.3 -m | grep curl
If the extension is installed but not appearing, restart the PHP handler:
# For PHP-FPM
sudo systemctl restart php8.3-fpm
# For Apache mod_php
sudo systemctl restart apache2
Fix “Unable to Locate Package php8.3” Error
This error typically means the Sury PPA was not added correctly or the package index was not refreshed after adding it. First, verify the PPA is configured:
apt-cache policy | grep ondrej
If no output appears, the PPA is not active. Re-add it and refresh the package index:
sudo add-apt-repository ppa:ondrej/php -y
sudo apt update
Then confirm PHP 8.3 is available:
apt-cache policy php8.3
On Ubuntu 22.04, the PPA is required for PHP 8.3 since the default repositories only include PHP 8.1. On Ubuntu 24.04, PHP 8.3 is available in the default repositories without the PPA, though the PPA provides newer point releases.
Update PHP 8.3 on Ubuntu
PHP 8.3 receives updates through the Sury PPA. Consequently, to update to the latest point release while keeping other system packages unchanged, run:
sudo apt update
sudo apt install --only-upgrade php8.3*
This command updates all PHP 8.3 packages (CLI, FPM, extensions) without upgrading unrelated system packages. After updating, restart PHP-FPM to apply changes:
sudo systemctl restart php8.3-fpm
Then, verify the new version:
php8.3 --version
Useful Links
For additional resources and documentation:
- PHP Official Website: Visit the official PHP website for information about the programming language, its features, and download options.
- PHP 8.3 Release Notes: Explore the release notes for PHP 8.3 to learn about new features, improvements, and changes.
- PHP 8.3 ChangeLog: Review the changelog for PHP 8 to see the detailed list of changes and updates in each release.
- PHP Documentation: Access comprehensive documentation for detailed guides on using and programming with PHP.
- PHP Supported Versions: Check current PHP version support status and end-of-life dates.
Ubuntu 24.04 LTS (Noble Numbat) includes PHP 8.3 in its default repositories at version 8.3.6. You can install it directly with sudo apt install php8.3 without adding any third-party PPAs. For the latest point releases (currently 8.3.30), add the Ondrej Sury PPA.
Install PHP 8.3 extensions using the php8.3- prefix with apt. For example: sudo apt install php8.3-{curl,mysql,gd,mbstring,xml,zip,intl}. Several extensions like tokenizer, openssl, PDO, json, filter, and session are bundled with the php8.3-common package and do not need separate installation.
Yes. The Ondrej Sury PPA packages each PHP version independently, so you can install PHP 8.1, 8.2, 8.3, and 8.4 side by side. Use update-alternatives --config php to switch the CLI version, and configure different PHP-FPM pools for each virtual host to serve different PHP versions simultaneously.
This error means the Sury PPA is not configured or the package index is outdated. Run sudo add-apt-repository ppa:ondrej/php -y followed by sudo apt update, then retry the installation. On Ubuntu 22.04 the PPA is required; on Ubuntu 24.04, PHP 8.3 is in the default repositories.
Conclusion
With PHP 8.3 installed on Ubuntu, you now have typed class constants, json_validate(), and readonly property cloning available for your applications, backed by Sury PPA security patches through December 2027. To build on this foundation, set up Composer for dependency management, configure Redis or Memcached for object caching, or enable Nginx FastCGI caching for production traffic.
Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags:
<code>command</code>command<pre>block of code</pre><strong>bold</strong><em>italic</em><a href="URL">link</a><blockquote>quote</blockquote>