Skip to Content

Upgrade PHP to 8.1 or 8.3 on Debian 9, 10, and 11 Servers

record ssh session

How to upgrade PHP to 8.1 & 8.3 in the Debian 9, 10, and 11 servers?


Overview: This article provides a step-by-step guide to upgrading PHP to version 8.1 or 8.3 on different Debian versions.


Step 1: Run the following command to install essential packages in the Debian server:

root@localhost:~$ apt install -y lsb-release apt-transport-https ca-certificates wget

Step 2: The Sury PHP repository is the recommended source for the latest PHP versions on Debian. Add it using the following commands:

root@localhost:~$ wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg

root@localhost:~$ echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list

Step 3: Run the below to update outdated packages and install PHP 8.1 or 8.3

root@localhost:~$ apt update

root@localhost:~$ apt install php8.1 -y

root@localhost:~$ apt install php8.3 -y

Step 4:. Run the below command to install 8.1 or 8.3 modules

root@localhost:~$ apt install php8.1-cli php8.1-xml php8.1-gd php8.1-curl php8.1-mysql php8.1-ldap php8.1-zip -y

root@localhost:~$ apt install php8.3-cli php8.3-xml php8.3-gd php8.3-curl php8.3-mysql php8.3-ldap php8.3-zip -y

Step 5:. Run the below command to confirm PHP 8.1 or 8.3 has been successfully installed in the Debian server

root@localhost:~$ php -v


PHP 8.2.25 (cli) (built: Mar 13 2025 17:33:36) (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
PHP 8.3.19 (cli) (built: Mar 13 2025 17:33:36) (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 6:. Add a PHP info page to confirm 8.1 has loaded for the webserver.

root@localhost:~$ vim /var/www/html/phpinfo.php

<?php
phpinfo();
?>

Related Articles:

How to install Ioncube on Jump server?

How to upgrade PHP to 7.4 on Centos 7?

How to upgrade PHP to 8.1 in Ubuntu?

How to install and switch different versions of PHP in Ubuntu?