In this article you will learn how to install PHP on Ubuntu 20.04 systems and how to configure it with basic extensions and minimum configuration settings.
Install PHP on Ubuntu 20.04
Step-1 Update RepositoriesUpdate your Ubuntu system repositories before proceeding for PHP installation using command.
$ sudo apt update
Step-2 Install PHP
After updating is complete first make sure to install which version of "PHP". To install a particular version of "PHP" run the following command.
$ sudo apt install -y php7.x
Here 7.X represents the verison of PHP you want to install. Replace this with your required version.
Step-3 Verify PHP InstallationNow verify your PHP installation by running the following command to check it's installed version. Please see below screeshot for reference.
$ php -v
If you could able to see the version means PHP is successfully installed on your Ubuntu machine.
Step-4 Install PHP ModulesYou can check for all available PHP modules for installation using the following command.
$ sudo apt-cache search php7*
Now you have to install required PHP modules for your application by running the following command.
$ sudo apt install php7.x-common php7.x-gmp php7.x-curl php7.x-intl php7.x-mbstring php7.x-xmlrpc php7.x-mysql php7.x-gd php7.x-bcmath php7.x-xml php7.x-cli php7.x-zip
In the above command replace php7.x with your required PHP verison. For ex:php7.x-mbstring will install "mbstring" extension. In this way we can install multiple modules using a single command.
Hope by now you should get successfully installed PHP and its modules on your Ubuntu machine. Happy coding.