UpgradeUbuntu to PHP 8

This page provides instructions on how to upgrade Ubuntu from PHP7 to PHP8. Much of the information for this page came from this link. https://devanswe.rs/how-to-upgrade-from-php-7-x-to-php-8-on-ubuntu-apache/

Check Ubuntu Version

Ensure your Ubuntu is at least 20.04. To do this run this command in Ubuntu.

lsb_release -a

Remove PHP7

Once you have confirmed that you are on the right version of Ubuntu remove your current version of PHP by running this command.

sudo apt-get purge php7.*

If prompted press yes.

To remove remaining elements of PHP7 run these two following commands.

sudo apt-get autoclean

sudo apt-get autoremove

Press yes if prompted.

Install PHP8

sudo apt-get install php8.1 php8.1-cli php8.1-mbstring unzip php8.1-gd php8.1-zip php8.1-xml php8.1-curl php8.1-imagick

sudo apt-get update

sudo add-apt-repository ppa:ondrej/php

sudo apt -y install software-properties-common

sudo apt-get update

sudo apt-get update

curl --version

php --version

And you should be good.