Note that PHP 7.x is the supported stable version in the Ubuntu software repositories, you can confirm this by running.
- Sudo apt show php
To install the default PHP version from the Ubuntu software repositories, use the command below.
1. Install PHP (5.6, 7.0, 7.1) on Ubuntu Using PPA
2. Next, update the system as follows.
3. Now install different supported versions of PHP as follows.
For Apache Web Server
For Nginx Web Server
4. Now you can install most required PHP modules from the list.