How to Install PHP 8.3 on Debian 12, 11 or 10

This guide demonstrates the process of how to install PHP 8.3 on Debian 12, 11, or 10 Linux using the command-line terminal and a well-known third-party PPA by Ondřej Surý.

PHP 8.3 stands as a pivotal release in the evolution of PHP, a widely used scripting language integral to web development. Below are some key features of PHP 8.3:

  • Typed Class Constants: Offering explicit typing for class constants, PHP 8.3 strengthens type enforcement and improves error detection.
  • Dynamic Class Constant Fetch: This addition simplifies accessing class constants, enhancing code readability and maintainability.
  • New #[\Override] Attribute: This feature checks the existence of a method with the same name in a parent class or interface, boosting code reliability and simplifying refactoring.
  • Deep-Cloning of Readonly Properties: PHP 8.3 enables modification of readonly properties within the __clone method, allowing for comprehensive cloning of such properties.
  • New json_validate() Function: This function provides an efficient means to validate JSON strings.
  • New Randomizer::getBytesFromString() Method: Building on the Random Extension from PHP 8.2, this method aids in generating random strings of specific bytes, useful for tasks like creating random identifiers.
  • Additional Methods and Functions: PHP 8.3 introduces various new methods and functions, enhancing the language’s versatility and utility.

Alongside these features, PHP 8.3 continues to deliver performance improvements, bug fixes, and general optimizations, further cementing PHP’s status as a powerful and reliable tool for web developers.

Next, we will explore the step-by-step process of installing PHP 8.3 on Debian, ensuring you can fully utilize these advancements in your development projects.

Import PHP 8.3 APT Repository on Debian

Update Debian System Prior to PHP 8.3 Installation

Ensure your Debian system is up-to-date before proceeding with the PHP 8.3 installation. This step is crucial for maintaining system security and enhancing compatibility with new software. Start by refreshing your package list and upgrading existing packages.

Use the following commands in your terminal:

sudo apt update
sudo apt upgrade

Install Prerequisite Packages for PHP Repository

To prepare your Debian system for PHP 8.3, you need to install packages that aid in managing additional repositories securely. These packages are essential for certificate authentication and software properties management.

Execute this command to install the necessary packages:

sudo apt install ca-certificates apt-transport-https software-properties-common lsb-release -y

Add PHP 8.3 APT Repository

For the latest PHP versions, adding Ondřej Surý’s PHP PPA to your Debian system is necessary. This repository provides more current PHP packages than the default ones available in Debian.

To import this repository, use the command below:

curl -sSL | sudo bash -x

After adding the repository, update your package cache to recognize the newly added source:

sudo apt update

Option 1: Install PHP 8.3 as an Apache Module

For systems using the Apache HTTP server, installing PHP as a module is a common approach that enhances server functionality. To install PHP 8.3 on Debian as an Apache module, use the following command:

sudo apt install php8.3 libapache2-mod-php8.3

After the installation completes, restart Apache to activate the new PHP 8.3 module:

sudo systemctl restart apache2

Option 2: Install Apache with PHP-FPM 8.3

PHP-FPM (FastCGI Process Manager) is a preferred choice for high-traffic websites, providing significant performance improvements. To install PHP 8.3 with PHP-FPM for Apache on Debian, execute:

sudo apt install php8.3-fpm libapache2-mod-fcgid

Next, enable PHP-FPM with these commands:

sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php8.3-fpm

Conclude by restarting Apache to apply these configurations:

sudo systemctl restart apache2

Option 3: Install PHP 8.3 Support for Nginx

Nginx, a popular web server, uses PHP-FPM to process PHP files efficiently. To install PHP 8.3 and PHP-FPM for Nginx on Debian, use this command:

sudo apt install php8.3 php8.3-fpm php8.3-cli

If PHP-FPM 8.3 doesn’t automatically start, enable and start it with:

sudo systemctl enable php8.3-fpm --now

Configuring Nginx Server Block for PHP-FPM 8.3

To configure Nginx to handle PHP files with PHP-FPM 8.3, modify the Nginx server block as follows:

location ~ .php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;

To ensure the configuration is correct, validate your Nginx configuration syntax:

sudo nginx -t

A successful validation will display:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Then, restart Nginx to implement your modifications:

sudo systemctl restart nginx

Verifying PHP 8.3 Installation via CLI

To confirm the successful installation of PHP 8.3, use the command:

php --version

This command displays the current PHP version, verifying that your installation or upgrade to PHP 8.3 is successful.

Terminal showing PHP 8.3 version on Debian
Confirming PHP 8.3 Installation via Terminal

Install PHP 8.3 Extensions on Debian

Installing PHP 8.3 Extensions

Customizing PHP 8.3 to meet the specific needs of your project is crucial for optimizing performance and security on Debian. To install the desired extensions, use the command format below:

sudo apt install php8.3-{cli,fpm,curl,mysqlnd,gd,opcache,zip,intl,common,bcmath,imagick,xmlrpc,readline,memcached,redis,mbstring,apcu,xml,dom,memcache,xdebug,soap,json,mbstring}

Understanding PHP 8.3 Extensions

  • php-cli: Essential for running PHP scripts in the command line.
  • php-fpm: FastCGI Process Manager, vital for efficient request handling.
  • php-curl: Enables server communication, critical for web requests.
  • php-mysqlnd: MySQL Native Driver, key for database interactions.
  • php-gd: A library for image manipulation and processing.
  • php-opcache: Improves PHP performance by caching precompiled script bytecode.
  • php-zip: Manages zip file operations, including compression and extraction.
  • php-intl: Supports internationalization and character sets.
  • php-common: Provides common functionalities across various PHP modules.
  • php-bcmath: Handles precise floating-point arithmetic operations.
  • php-imagick: Image processing capabilities using ImageMagick.
  • php-xmlrpc: Facilitates XML-RPC server and client functions.
  • php-readline: Improves interactive terminal input.
  • php-memcached & php-redis: Enhance caching for better performance.
  • php-mbstring: Manages multibyte character encodings.
  • php-apcu: Offers user caching to enhance PHP application performance.
  • php-xml & php-dom: Essential for XML parsing and manipulation.
  • php-xdebug: A debugger and profiler for PHP development.
  • php-soap: Used for SOAP protocol and web services.
  • php-json: Handles JSON data format in PHP applications.

For a comprehensive search of available modules, use:

sudo apt search php8.3-
Terminal search for PHP 8.3 packages on Debian
Searching for Additional PHP 8.3 Packages

Monitoring Installed PHP 8.3 Modules

To maintain system efficiency, it’s crucial to monitor and manage your PHP modules regularly.

To list all the loaded PHP 8.3 modules, execute:

php8.3 -m
Listing PHP 8.3 extensions in Debian terminal
Display of Installed PHP 8.3 Extensions

Install PHP 8.3 Development Tools

For advanced PHP development and debugging, the following tools are indispensable:

sudo apt install php8.3-pcov php8.3-dev

These tools include php8.3-pcov for code coverage analysis and php8.3-dev for development and compilation tasks.

Run PHP 8.3 Alongside Other PHP Versions on Debian

Managing Multiple PHP Versions

Debian users can install PHP 8.3 alongside other PHP versions. When installing PHP 8.3, the system 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. For PHP 8.3, this means applications calling PHP CLI as php will use the last-installed PHP-CLI binary, which is PHP 8.3 in this scenario. When working with multiple PHP versions, it’s essential to invoke the correct PHP binary by directly calling the /usr/bin/phpX.Y executable. For instance, PHP 8.3 can be invoked directly as /usr/bin/php8.3.

Configuring the Default PHP CLI Version

The default php command is symlinked to the most recently installed PHP version. However, it’s possible to change this default behavior to link to a different PHP version. The update-alternatives command facilitates this configuration change.

To configure which PHP binary the php command points to, execute:

sudo update-alternatives --config php

This command presents an interactive prompt allowing the selection of an alternative PHP binary path for the php command. The prompt displays the available choices:

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.1   81        manual mode
  3            /usr/bin/php7.4   74        manual mode

To set the PHP path without using the interactive prompt, use the following command:

sudo update-alternatives --set php /usr/bin/php8.2

This command immediately updates the default PHP CLI binary to the specified version, in this case, PHP 8.2. Remember to replace /usr/bin/php8.2 with the desired PHP version path, such as /usr/bin/php8.1 or /usr/bin/php7.4, depending on your specific requirements.


To wrap up, this guide has meticulously walked you through installing PHP 8.3 on Debian 12, 11, or 10. We’ve covered everything from updating your system and adding PHP repositories to installing various PHP extensions that cater to diverse development needs. Moreover, we addressed running multiple PHP versions concurrently, ensuring flexibility for various projects. As a final recommendation, regularly monitor and update your PHP installations to maintain security and efficiency.

Leave a Comment

Your Mastodon Instance
Share to...