How upgrade PHP 8.1 to 8.2 or 8.3 using ondrej repository on ubuntu 22

Las update: 25-October-2024

In this article we will upgrade from PHP 8.1 to PHP 8.1 using ondrej repository.

This just work with ondrej repository, for more informaction about this repository 



If you have installed PHP 8.1 you will need install additional PHP 8.2 for upgrade after using a command. This work for apache on linux.

Please note that you have to add each version of PHP as you need it, you can have as many versions as they are released, as of the date this article was written (October 2024) the latest version is 8.3.

Follow this steps.


Install PHP 8.2


sudo apt install php8.2


or for PHP 8.3 depending on the version of PHP you want to add.


sudo apt install php8.3



Install modulos for PHP 8.2. 

Please change all the places where it says "8.2" to the version you want to install, this can be "8.1" or "8.2" or "8.3" and so on depending on the existing versions at the moment.

sudo apt install php8.2-common php8.2-mysql php8.2-xml php8.2-xmlrpc php8.2-curl php8.2-gd php8.2-imagick php8.2-cli php8.2-dev php8.2-imap php8.2-mbstring php8.2-opcache php8.2-soap php8.2-zip php8.2-intl -y



You can't be enabled bouth php version, you need first disable one and enable other version.

Important note. Remember that apache can have a different version of php than CLI, I recommend you have the same version for work fine. Thats means you should chang both version Apache (Web server) and CLI.

Disable PHP 8.1

sudo a2dismod php8.1

Enable PHP 8.2

sudo a2enmod php8.2


Restart Apache services


sudo service apache2 restart

Switch between PHP versions on ubuntu

You can switch between version, for this example you need has installed one or more version of PHP.


sudo update-alternatives --config php

You will see this screen.



In this case I have installed two versions php8.1 and php8.2, you can select ther version that you wish writing the number and key enter.


Restart Apache services


sudo service apache2 restart



References.

https://www.thedataops.org/how-to-upgrade-php-version-from-8-1-to-8-2-in-ubuntu/


Comments