PHP 8.3 delivers typed class constants, the #[\Override] attribute for safer refactoring, deep-cloning of readonly properties, the json_validate() function, and continued performance improvements over previous releases. Installing PHP 8.3 on Debian requires adding the Sury PHP repository because Debian’s default repositories ship different PHP versions: PHP 8.4 on Debian 13, PHP 8.2 on Debian 12, and PHP 7.4 on Debian 11.
This guide walks through two methods for importing the Sury repository: the streamlined extrepo tool and manual repository configuration. You will also learn how to install PHP 8.3 with Apache or Nginx, configure PHP-FPM for high-traffic sites, and manage multiple PHP versions side by side. After completing these steps, you will have a working PHP 8.3 environment ready for WordPress, Laravel, or any PHP application.
Choose Your Repository Configuration Method
Debian provides two approaches for adding the Sury PHP repository. The extrepo method handles GPG keys and repository configuration automatically, while manual configuration offers full control over repository settings.
| Method | GPG Key Management | Debian Support | Steps Required | Best For |
|---|---|---|---|---|
| extrepo (Recommended) | Automatic | 11, 12, 13 | 3 commands | Most users; quick setup with minimal configuration |
| Manual Repository | Manual download | 11, 12, 13 | 5 commands | Scripted deployments, custom configurations, or learning APT internals |
For most users, the extrepo method is recommended because it simplifies repository management and reduces manual steps. Debian’s extrepo tool maintains a curated list of external repositories with verified GPG keys, making it the safest approach for adding third-party sources.
Choose Your PHP Version for Debian
Compare Supported PHP Releases
Each PHP version targets different support lifecycles and compatibility needs. Debian’s default repositories provide stable PHP versions maintained by the Debian security team, while the Sury repository offers current releases with upstream security support.
| PHP Version | Primary Focus | Performance | Best For | Trade-offs |
|---|---|---|---|---|
| PHP (Distro Default) | Stability with Debian security team maintenance | Varies by version; Debian 12’s PHP 8.2 includes JIT compilation and OPcache | Production servers prioritizing official Debian updates and minimal external dependencies | Version varies by release (8.4 on Debian 13, 8.2 on Debian 12, 7.4 on Debian 11) |
| PHP 8.5 | Pipe operator, URI extension, clone with properties, array helpers | Improved JIT and continued IR-based JIT framework refinements | Projects leveraging function chaining, advanced URL handling, or needing array_first()/array_last() | Newest release; requires Sury repository on all Debian versions |
| PHP 8.4 | Property hooks, asymmetric visibility, HTML5 DOM API | Continued JIT improvements; new IR-based JIT framework | Projects using modern OOP patterns, applications requiring array_find() and BCMath object API | Requires Sury repository on Debian 11/12; available in Debian 13 default repositories |
| PHP 8.3 | Typed class constants, json_validate(), readonly property cloning | Mature JIT optimization with broad extension compatibility | WordPress 6.x, Laravel 11, Drupal 10 sites needing stable features with security support through December 2027 | Requires Sury repository on all Debian versions; community-maintained updates |
Recommendation: Choose PHP 8.3 when your applications require typed class constants, json_validate(), or readonly property cloning while benefiting from broad ecosystem compatibility. WordPress 6.x, Laravel 11, and Drupal 10 all run well on PHP 8.3 with security support through December 2027. If you need the pipe operator or array_first()/array_last() helpers, consider PHP 8.5. Alternatively, consider PHP 8.4 if you need property hooks or the new HTML5 DOM API, or choose the distro default PHP when you prefer official Debian security team maintenance.
Decide When to Use PHP 8.3
Install PHP 8.3 from the Sury repository when your application requires features unavailable in Debian’s default PHP packages, or when you need the extended security support timeline through December 2027. The Sury repository provides timely updates but operates independently from Debian’s security team, so production deployments should monitor PHP security advisories directly.
Import PHP 8.3 APT Repository on Debian
Update Debian System Before PHP 8.3 Installation
Before adding external repositories, update your existing packages to ensure dependency resolution works correctly. Run the following commands to refresh the package index and apply any pending upgrades:
sudo apt update
sudo apt upgrade
Method 1: Use extrepo (Recommended)
The extrepo tool automates external repository management by handling GPG keys and source file creation. First, install extrepo and its dependencies:
sudo apt install extrepo -y
Next, enable the Sury PHP repository:
sudo extrepo enable sury
The extrepo command creates the repository configuration at /etc/apt/sources.list.d/extrepo_sury.sources and places the GPG key at /var/lib/extrepo/keys/sury.asc. Once enabled, refresh the package index:
sudo apt update
Verify PHP 8.3 is now available from the Sury repository:
apt-cache policy php8.3
Expected output:
php8.3:
Installed: (none)
Candidate: 8.3.x+0~YYYYMMDD+debianXX
Version table:
8.3.x+0~YYYYMMDD+debianXX 500
500 https://packages.sury.org/php [codename]/main amd64 Packages
The version string, date, and codename (bullseye, bookworm, or trixie) in your output will reflect your Debian version and the current PHP 8.3 release available at the time of installation.
If the output shows a candidate version from packages.sury.org, skip to the Install PHP 8.3 on Debian section below.
Method 2: Manual Repository Configuration
For scripted deployments or when you need full control over repository configuration, add the Sury repository manually. First, install the required packages:
sudo apt install ca-certificates curl gnupg lsb-release -y
The
lsb-releasepackage provides thelsb_releasecommand used below for automatic release detection. This package is not installed by default on minimal Debian installations.
Download and install the Sury PHP repository GPG keyring package:
curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
sudo dpkg -i /tmp/debsuryorg-archive-keyring.deb
Next, create the repository configuration file using the modern DEB822 .sources format:
cat <<EOF | sudo tee /etc/apt/sources.list.d/php.sources
Types: deb
URIs: https://packages.sury.org/php/
Suites: $(lsb_release -cs)
Components: main
Signed-By: /usr/share/keyrings/debsuryorg-archive-keyring.gpg
EOF
Debian 13 defaults to DEB822
.sourcesfor APT entries. Debian 12 and Debian 11 also support.sources, though legacy.listfiles remain common on older installations.
Finally, refresh the package index and verify PHP 8.3 availability:
sudo apt update
apt-cache policy php8.3
Expected output:
php8.3:
Installed: (none)
Candidate: 8.3.x+0~YYYYMMDD+debianXX
Version table:
8.3.x+0~YYYYMMDD+debianXX 500
500 https://packages.sury.org/php [codename]/main amd64 Packages
Install PHP 8.3 on Debian
Choose the installation option that matches your web server. Apache users can select either mod_php (simpler configuration) or PHP-FPM (better performance under load). Nginx requires PHP-FPM exclusively.
Option 1: Install PHP 8.3 with Apache mod_php
The mod_php approach embeds PHP directly into Apache, therefore making configuration straightforward for smaller sites. Install PHP 8.3 as an Apache module:
sudo apt install php8.3 libapache2-mod-php8.3
Then, restart Apache to activate the new PHP module:
sudo systemctl restart apache2
Verify PHP is loaded in Apache:
php --version
Expected output:
PHP 8.3.x (cli) (built: ...)
Copyright (c) The PHP Group
Zend Engine v4.3.x, Copyright (c) Zend Technologies
with Zend OPcache v8.3.x, Copyright (c), by Zend Technologies
Option 2: Install PHP 8.3 with Apache and PHP-FPM
PHP-FPM (FastCGI Process Manager) handles PHP requests in a separate process pool, thereby providing better performance and resource isolation for high-traffic sites. Install PHP-FPM with Apache:
sudo apt install php8.3-fpm libapache2-mod-fcgid
If you previously installed mod_php (libapache2-mod-php8.3), disable it before using PHP-FPM to avoid handler conflicts:
sudo a2dismod php8.3
Subsequently, enable the required Apache modules and PHP-FPM configuration:
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php8.3-fpm
Afterwards, restart Apache to apply the configuration:
sudo systemctl restart apache2
Verify PHP-FPM is running:
sudo systemctl status php8.3-fpm
Expected output showing active status:
● php8.3-fpm.service - The PHP 8.3 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php8.3-fpm.service; enabled)
Active: active (running)
Option 3: Install PHP 8.3 with Nginx and PHP-FPM
Nginx uses PHP-FPM exclusively to process PHP files. Install PHP 8.3 with the FPM and CLI packages:
sudo apt install php8.3 php8.3-fpm php8.3-cli
Once installed, enable and start PHP-FPM:
sudo systemctl enable php8.3-fpm --now
Then, verify PHP-FPM is running:
sudo systemctl status php8.3-fpm
Expected output showing active status:
● php8.3-fpm.service - The PHP 8.3 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php8.3-fpm.service; enabled)
Active: active (running)
Configure Nginx Server Block for PHP-FPM
Add the following location block to your Nginx server configuration to process PHP files 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, validate the Nginx 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
If validation passes, restart Nginx to apply the configuration:
sudo systemctl restart nginx
Verify PHP 8.3 Installation
Confirm PHP 8.3 installed correctly by checking the version:
php --version
Expected output:
PHP 8.3.x (cli) (built: ...)
Copyright (c) The PHP Group
Zend Engine v4.3.x, Copyright (c) Zend Technologies
with Zend OPcache v8.3.x, Copyright (c), by Zend Technologies
Install PHP 8.3 Extensions on Debian
Install Common PHP 8.3 Extensions
Most PHP applications require additional extensions beyond the base installation. Therefore, install a comprehensive set of commonly needed extensions for WordPress, Laravel, and general PHP development:
sudo apt install php8.3-{curl,mysql,gd,opcache,zip,intl,common,bcmath,imagick,xmlrpc,readline,memcached,redis,mbstring,apcu,xml,xdebug,soap}
JSON support is built into PHP 8.0 and newer, so there is no separate
php8.3-jsonpackage to install. Thephp8.3-xmlpackage includes DOM, SimpleXML, XMLReader, and XMLWriter support.
Extension Reference
In particular, the extensions above provide the following functionality:
- php-curl: Enables HTTP requests and API communication.
- php-mysql: MySQL and MariaDB database connectivity.
- php-gd: Image manipulation and processing library.
- php-opcache: Bytecode caching for improved PHP performance.
- php-zip: ZIP archive compression and extraction.
- php-intl: Internationalization and locale support.
- php-bcmath: Arbitrary precision mathematics.
- php-imagick: Advanced image processing via ImageMagick.
- php-xmlrpc: XML-RPC protocol support for remote procedure calls.
- php-memcached and php-redis: Distributed caching backends for session storage and object caching. See the Redis on Debian and Memcached on Debian guides for server setup.
- php-mbstring: Multibyte string handling for UTF-8 and international text.
- php-apcu: User-level opcode caching for application data.
- php-xml: XML parsing including DOM, SimpleXML, and XSL transformations.
- php-xdebug: Debugger and profiler for development environments.
- php-soap: SOAP web services protocol support.
Additionally, for a comprehensive search of available modules, use:
apt search php8.3-
Example output showing available extensions:
Sorting... Full Text Search... php8.3-amqp/[codename] x.x.x amd64 AMQP extension for PHP php8.3-apcu/[codename] x.x.x amd64 APC User Cache for PHP php8.3-bcmath/[codename] 8.3.x amd64 Bcmath module for PHP [additional packages...]
List Installed PHP 8.3 Extensions
View all loaded PHP 8.3 modules to confirm which extensions are active:
php8.3 -m
Example output showing loaded modules:
[PHP Modules] calendar Core ctype curl date 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
For PHP development and code coverage testing, install the development packages:
sudo apt install php8.3-pcov php8.3-dev
The php8.3-pcov package provides lightweight code coverage analysis, while php8.3-dev includes headers and tools needed to compile PHP extensions from source.
Run PHP 8.3 Alongside Other PHP Versions on Debian
Managing Multiple PHP Versions
You can install PHP 8.3 alongside other PHP versions on the same Debian system. Installing PHP 8.3 does not remove older PHP packages, allowing multiple versions to coexist.
Each phpX.Y-cli package installs its PHP CLI binary at /usr/bin/phpX.Y. The Debian alternatives system selects the default php binary based on priority numbers assigned during package installation. PHP 8.3 registers with priority 83, PHP 8.2 with 82, and so on, with the higher priority winning in auto mode. When working with multiple PHP versions, you can invoke a specific version directly as /usr/bin/php8.3 regardless of the default.
Configuring the Default PHP CLI Version
By default, the php command links to the PHP version with the highest priority. To change which version the php command invokes, use update-alternatives.
To configure which PHP binary the php command points to, execute:
sudo update-alternatives --config php
This command displays an interactive menu where you can select the PHP version to use as the default. Example output with multiple versions installed:
There are 4 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.1 81 manual mode 3 /usr/bin/php7.4 74 manual mode
Alternatively, to set the PHP path without using the interactive prompt, use the following command:
sudo update-alternatives --set php /usr/bin/php8.3
This command immediately sets the default PHP CLI binary to PHP 8.3 in manual mode. Replace /usr/bin/php8.3 with another path like /usr/bin/php8.2 or /usr/bin/php8.1 if your application requires a specific version.
Troubleshoot Common PHP 8.3 Issues
PHP-FPM Socket Not Found
If Nginx returns a 502 Bad Gateway error, check the Nginx error log for the actual message:
sudo tail -20 /var/log/nginx/error.log
A socket connection failure appears as:
connect() to unix:/var/run/php/php8.3-fpm.sock failed (2: No such file or directory)
Verify the socket file exists:
ls -la /var/run/php/php8.3-fpm.sock
Expected output if PHP-FPM is running correctly:
srw-rw---- 1 www-data www-data 0 Dec 4 10:00 /var/run/php/php8.3-fpm.sock
If the socket is missing, check PHP-FPM status:
sudo systemctl status php8.3-fpm
Look for Active: active (running) in the output. If the service is inactive or failed, restart it:
sudo systemctl restart php8.3-fpm
Verify the socket now exists:
ls -la /var/run/php/php8.3-fpm.sock && sudo systemctl status php8.3-fpm --no-pager | head -5
Wrong PHP Version Active
When php --version shows an unexpected PHP version, check the current alternatives configuration:
update-alternatives --query php
The output shows the current selection and available alternatives:
Name: php Link: /usr/bin/php Status: auto Best: /usr/bin/php8.3 Value: /usr/bin/php8.2 Alternative: /usr/bin/php8.2 Priority: 82 Alternative: /usr/bin/php8.3 Priority: 83
In this example, the Best version (php8.3) differs from the current Value (php8.2), indicating manual mode is active. To switch to PHP 8.3:
sudo update-alternatives --set php /usr/bin/php8.3
Verify the change:
php --version
For web servers, ensure your Apache or Nginx virtual host configuration references the correct PHP-FPM socket path (/var/run/php/php8.3-fpm.sock).
Extension Not Loading
If an extension fails to load, first verify it is installed:
dpkg -l | grep php8.3-curl
Expected output for an installed extension:
ii php8.3-curl 8.3.x+0~YYYYMMDD+debianXX amd64 CURL module for PHP
Check if the extension appears in the loaded modules list:
php8.3 -m | grep -i curl
If installed but not loading, check for configuration errors:
php8.3 -i 2>&1 | grep -i error
Additionally, check the PHP-FPM error log for module loading failures:
sudo tail -50 /var/log/php8.3-fpm.log
After fixing any configuration issues, restart PHP-FPM:
sudo systemctl restart php8.3-fpm
Remove PHP 8.3 from Debian
To remove PHP 8.3 and its extensions, start by uninstalling the packages:
sudo apt remove --purge php8.3*
sudo apt autoremove
Remove Repository (extrepo Method)
If you added the Sury repository using extrepo, disable and remove it:
sudo extrepo disable sury
sudo rm /etc/apt/sources.list.d/extrepo_sury.sources
Remove Repository (Manual Method)
If you added the repository manually, remove the sources file and keyring package:
sudo rm /etc/apt/sources.list.d/php.sources
sudo apt remove debsuryorg-archive-keyring
Verify Removal
Refresh the package cache and confirm PHP 8.3 is no longer available:
sudo apt update
apt-cache policy php8.3
Expected output after removal:
php8.3: Installed: (none) Candidate: (none)
Conclusion
Your Debian 13, 12, or 11 system now runs PHP 8.3 from the Sury repository with Apache or Nginx, including extensions for database connectivity, caching, and image processing. The update-alternatives system lets you switch between PHP versions when projects require different interpreters.
For production deployments, consider installing Composer for dependency management, set up MySQL or MariaDB for database storage, and configure SSL certificates to serve PHP applications securely. Furthermore, for database administration, phpMyAdmin with Nginx provides a web-based interface for managing your databases.