In this tutorial, we’ll be going through the steps to install PHP on Ubuntu Linux machine.
Environment: Ubuntu Linux Server LTS.
Log in with a user having sudo privileges.
Open Terminal window.
Issue the following command
$ sudo apt install php
Install PHP extensions
PHP extensions are available as packages and can extend the functionality of PHP instance.
To install a new PHP extension, we can run the command in the terminal window as shown.
$ sudo apt install <php extension name>
For example, if we want to install MySql extension we can run the following command
$ sudo apt install php-mysql
Open a terminal window and type the following command.
$ php -version