Good news! PHP 7.1 is being actively supported through 20 Sep 2024. After that point, it's advisable to upgrade to the latest version, since the PHP team will only offer security-related support until 20 Sep 2024, at which point PHP 7.1 will be considered "end-of-life".
Add the PHP 7.1 PPA repository:
sudo add-apt-repository ppa:ondrej/php
Update the package list:
sudo apt update
Install PHP 7.1:
sudo apt install php7.1
Install common PHP extensions:
sudo apt install php7.1-cli php7.1-common php7.1-json php7.1-opcache php7.1-mysql php7.1-mbstring php7.1-mcrypt php7.1-zip
Check the PHP version:
php -v
You should see output indicating PHP 7.1.x is installed.
Verify PHP configuration:
php -i
This will display detailed PHP configuration information.
Check installed PHP modules:
php -m
This will list all installed PHP modules.