![](http://1.bp.blogspot.com/-_O2t5Ss9wQ0/XgitdsRtYZI/AAAAAAAASGY/H4o4C7ixFJkPuL3jsfivP6e9uAl2q3MnwCLcBGAsYHQ/s1600/PHP_Ubuntu.png)
This guide will show you how to install the different version of PHP on Ubuntu 16, 17, 18 and 19. For the sake of this tutorial, we are using Ubuntu 16 and PHP 7.1 as an example.
Enabling PPA
If you are on Ubuntu 16, the only version of PHP available in its default repository is 7.0 and therefor you need to add Ondrej’s PPA to get the PHP version of your choice:
Installing PHP 7.1
Once you enabled the ondrej/php PPA, you can install PHP 7.1 using the below command:To install PHP7.1 including some of the most commonly used modules you can use the following command:
Configuring PHP
Once the installation is completed you need to edit the php.ini file:Find the php.ini configuration file like below:
You will see the output similar to the following:
Output
Loaded Configuration File: /etc/php/7.1/cli/php.ini
Edit the file using your preferred text editor:
Make the following changes:
Then, restart the PHP-FPM service: