I got an old code, I wanted to run it on my ubuntu server which using php8.2, but it shows lots of errors, I didn’t want to change anything of the code, because maybe it would cost lots of time, so I should try to install php 5.6 on my server.

sudo apt update

sudo apt install -y software-properties-common
sudo add-apt-repository ppa:ondrej/php

sudo apt update

sudo apt install -y php5.6
sudo apt install -y php5.6-cli php5.6-fpm php5.6-mysql php5.6-curl php5.6-xml php5.6-mbstring php5.6-zip

sudo systemctl enable php5.6-fpm
sudo systemctl start php5.6-fpm

If you want to install php7.4, you could try the following commands.

apt install -y software-properties-common
add-apt-repository -y ppa:ondrej/php
apt update
apt-get upgrade
apt-get install php7
apt-get install php7.4
apt install -y php7.4-cli php7.4-curl php7.4-mbstring php7.4-xml php7.4-fpm php7.4-mysql php7.4-redis

php -v // Check the version of current php.
php -m // Check which extensionis working.