
Step 1 – Add PHP PPA
First of all, you need to configure repository on your system. Run the following command to add ondrej PHP repository to your Ubuntu system.
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
The above command will also update the packages information list. But if you already have repository added, then update the packages information before installing or updating package:
sudo apt update
Install PHP 7.4
Step 2 – Install Required PHP Version
PHP 7.4 is the latest stable version available for installation. To install PHP 7.4 on your Ubuntu system run command:
sudo apt install -y php7.4
Step 3 – Check PHP Version
php -v
PHP 7.4.8 (cli) (built: Jul 13 2020 16:46:22) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.8, Copyright (c), by Zend Technologies