How to install PHP (7 or 7.2) on Ubuntu

Finally, the third part of our LAMP tutorial series: how to install PHP on Ubuntu. In this tutorial, we'll show you how to install various versions of PHP, including PHP 7, and the latest PHP 7.2

This tutorial should work for any Ubuntu release and other Ubuntu-based releases. Ubuntu 14.04, Ubuntu 16.04, Ubuntu 18.04, even Ubuntu 17.10. It was tested and written for Ubuntu 16.04.

For the first part of our LAMP series, go to our How to Install and Optimize Apache on Ubuntu tutorial.

And for the second part, go to How to Install MySQL/MariaDB on Ubuntu.

And the third (PHP) part: How to install PHP (7 or 7.2) on Ubuntu