How to Install PHP on Ubuntu 20.04
PHP is one of the most used server-side programming languages. Many popular CMS and frameworks such as WordPress, Magento, and Laravel are written in PHP.
This guide covers the steps necessary to install PHP on Ubuntu 20.04 and integrate it with Nginx and Apache, postgresql database and mysql database.
Step 1. Update your system
sudo apt update
Step 2. Installing PHP 7.4 on Ubuntu 20.04
Ubuntu 20.04 ships php 7.4 in its upstream repositories. The installation is pretty straightforward, install it with apt package manager by typing the following command
sudo apt install php
Step 3. Verify the Installation
Once the installation is complete, verify it by typing curl --version to know the version of curl installed
php --version
The output will look something like this:
That’s it! You have successfully installed php
on your Ubuntu machine, and you can start using it.
Step 4. Installing php 7.4 with Apache
if you are using apache as your webserver, run the following command
sudo apt install libapache2-mod-php
The output will look something like this:
Step 5. Installing php-mysql extension
if you are using mysql as your database install the php-mysql extension to use it with php
sudo apt install php-mysql
The output will look something like this: