All Articles

Installing latest version of Php

PHP is a popular programming language commonly used for building web based applications. Most Linux distributions provide PHP out of the box. However the version of PHP in most cases is not the current stable version.

To install the latest stable version of PHP, we need to use a third part package repository such as deb.sury.org/. To use this repository we need to follow the instructions given on: https://packages.sury.org/php/README.txt.

After that we can install the latest version of PHP. For example to install PHP 7.2, we need to issue the commands:

apt-get update

followed by:

apt-get install php7.2

To revert to the version of PHP provided by the operating system, we need to remove the file: /etc/apt/sources.list.d/php.list. We also need to remove the package singing key for deb.sury. Next we need to run the commands:

apt-get update

followed by:

apt-get remove php7.2

After that we need to install the PHP package using:

apt-get install php

This will install the version of PHP that is provided by the operating system

Published Jun 28, 2018

Tutorials about Web Development, Server Management, Computer Science and more