Upgrade Default PHP to PHP 8.3 in Debian / Ubuntu

This tutorial intends to teach you to Upgrade the Default PHP version to PHP 8.3 in Debian / Ubuntu from the terminal command line. In the last guide, we talked about the newly released PHP version which is PHP 8.3. It has many features and improvements. Also, it will be released on 23 November 2023. So we decided to provide a guide for upgrading the PHP version to the new version in Debian-based distros.

You can find more information about PHP 8.3 by visiting this guide on Upcoming PHP 8.3 and New Improvements.

Now follow the steps below to start your Upgrade process for PHP on Debian and Ubuntu.

Steps To Upgrade Default PHP to PHP 8.3 in Debian / Ubuntu

Before you start, you must have access to your server as a non-root user with sudo privileges. You can visit the Orcacore website and get the Debian-based distros’ initial setup guides.

You can use any version of Ubuntu and Debian server like Ubuntu 22.04, Debian 12, Debian 11, Ubuntu 20.04, etc. In this guide, to show you the guide steps we use Debian 12 server.

Step 1 – Check Default PHP Version in Debian / Ubuntu

The first step is to check your current PHP version. The default PHP version in Debian 12 is PHP 8.2. To verify it, you can run the command below:

php -v
Output
PHP 8.2.7 (cli) (built: Jun  9 2023 19:37:27) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.7, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.7, Copyright (c), by Zend Technologies

Step 2 – Remove Default PHP in Debian / Ubuntu

Before you start to upgrade your PHP version, you must remove your current PHP version installed on your Debian-based server. To do this, you can use the following syntax:

sudo apt purge php8.* -y

When you are done, run the following commands to delete older versions of the packages that will never be required by you or the system:

# sudo apt autoclean
# sudo apt autoremove

Step 3 – Add PPA Repository To Get the Latest PHP Version

At this point, you must use the Ondřej Surý PPA repository to get PHP 8.3 in your Debian-based distros. First, install some required packages with the command below:

sudo apt -y install lsb-release apt-transport-https ca-certificates

Then, run the following wget command to add the PPA repository on Debian:

# sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
# sudo echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list

On Ubuntu servers, you can use the following command to add the PPA repository:

sudo add-apt-repository ppa:ondrej/php

When you are done, run the system update:

sudo apt update

Step 4 – Install PHP 8.3 in Debian / Ubuntu

At this point, you can get your PHP in the latest version which is PHP 8.3. To do this, you can run the command below:

sudo apt install php8.3 -y

When your installation is completed, verify it by checking its version:

php -v
Output
PHP 8.3.0RC5 (cli) (built: Oct 26 2023 07:21:59) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.0RC5, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.0RC5, Copyright (c), by Zend Technologies

As you can see, this is the RC version. Until 23 NOV it has been released, you can use it for testing. But the guide steps are the same.

Conclusion

At this point, you have learned to Upgrade the Default PHP version to PHP 8.3 in Debian / Ubuntu from the terminal command line. PHP 8.3 will be the latest stable release of PHP which will be released on 23 NOV. Hope you enjoy it.

Also, you may like these articles:

Find Apache and PHP Version Installed on Linux

Check if PHP is Working on Apache in Ubuntu

Disable or Hide Error Messages in PHP

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Stay informed and not overwhelmed, subscribe now!