Some WordPress plugins stopped working with PHP 7.0 on my Ubuntu 16.04 server and I switched to PHP 7.4 with the following commands:
sudo add-apt-repository ppa:jczaplicki/xenial-php74-temp
sudo apt-get update
sudo apt-get install php7.4 php7.4-fpm php7.4-cli php7.4-mysql php7.4-dom php7.4-mbstring -y
service php7.4-fpm status
cd /etc/php/7.4/fpm/pool.d
sudo mv www.conf www.conf.dist
sudo mv ../../../7.0/fpm/pool.d/devnote.conf .
sudo service php7.0-fpm reload
sudo service php7.4-fpm reload
Also tried the following:
sudo apt-get install software-properties-common gnupg2
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php8.1 php8.1-fpm php8.1-cli -y
sudo apt-get install php5.6 php5.6-fpm php5.6-cli -y
but without a success, because it does not work with Ubuntu 16.04, so I removed the repository:
sudo apt-get install ppa-purge
sudo ppa-purge ppa:ondrej/php
sudo apt update
php -m
sudo apt-get install php7.4-curl php7.4-imagick php7.4-zip php7.4-intl