How to Install PHP 8.3 on Debian 13

PHP stands for PHP: Hypertext Preprocessor, and is an open-source scripting language widely used by web developers for web development. It is widely used to create various projects such as graphical user interfaces (GUIs), dynamic websites, and others. PHP is versatile, easy to integrate with databases, and has a strong community support. Debian 13 ships with PHP 8.4, and in this article we will show you how to install PHP 8.3 on Debian 13.

Prerequisites

  • A Debian 13 server.
  • SSH root access, or user with sudo privileges.

Conventions

# – given commands should be executed with root privileges either directly as a root user or by use of sudo command
$ – given commands should be executed as a regular user

Step 1. Install Dependencies

We need to install some dependencies to proceed with installing PHP 8.3 in our Debian 13 system. Let’s install them by running this command below.

$ sudo apt install apt-transport-https ca-certificates gnupg

Step 2. Add Third Party Repository

Debian 13 has PHP 8.4 in its default repository. So, when installing from the Debian repository, we will get PHP 8.4. In order to install the less recent version of PHP, for example version 8.3 we need to add a third party repository. Let’s add SURY repository now and proceed with the installation.

First, let add the GPG key to our system

$ sudo curl -fsSL https://packages.sury.org/php/apt.gpg | sudo gpg --dearmor -o /usr/share/keyrings/sury-php.gpg

This third party repository provides older PHP packages for Debian. Now, let’s add the Sury repository to our Debian 13 system:

$ echo "deb [signed-by=/usr/share/keyrings/sury-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/sury-php.list

Next, we need to update the package list to get the more recent information of the packages we can install on the system

$ sudo apt update

Step 3. Install PHP 8.3 and Its Extensions

After updating the package information, we can finally install PHP and its common extension. You may want to edit the command below if you want to add more extensions.

$ sudo apt install php8.3-{cli,common,curl,gd,intl,mbstring,mysql,xml,fpm}

`That’s it, you have successfully installed PHP 8.3 on your Debian 13 server. If you already have PHP 8.4 installed on the server, you can run this command to check and see which other versions are installed.

$ update-alternatives --list php

The command will show you an output similar to this:

/usr/bin/php8.3
/usr/bin/php8.4

If you want to use PHP 8.3 as the default version, we can execute this command:

$ sudo update-alternatives --config php

The command above will print this message:

There are 2 choices for the alternative php (providing /usr/bin/php).

  Selection    Path             Priority   Status
------------------------------------------------------------
* 0            /usr/bin/php8.4   84        auto mode
  1            /usr/bin/php8.3   83        manual mode
  2            /usr/bin/php8.4   84        manual mode

Press <enter> to keep the current choice[*], or type selection number:  

As seen in the screen, we can type 1 to switch to PHP 8.3, press 1 then hit ENTER. Please note that you may need to choose the other number shown in your server. After hitting the ENTER key, you will get this message:

update-alternatives: using /usr/bin/php8.3 to provide /usr/bin/php (php) in manual mode

To check and confirm if we use PHP 8.3, we can invoke this command:

$ php -v

You will see this output:

PHP 8.3.24 (cli) (built: Aug  3 2025 08:52:32) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.24, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.24, Copyright (c), by Zend Technologies

That’s it, if you want to change which PHP version as the default version, you can re-run the update-alternatives command above.

Conclusion

Congratulation! You have learned how to install PHP 8.3 on Debian 13.

If you want to host your PHP based websites with high-end hardware at an affordable price, check out our VPS hosting plans and start hosting any software you want with dedicated resources.

If you liked this post on how to install PHP 8.3 on Debian 13, please share it with your friends or leave a reply below.

Leave a Comment