Hamsa K
Editor
4 min read | 4 years ago

How to Install PHP 7.4 on Ubuntu 18 04

How to Install PHP 7.4 on Ubuntu 18.04/19.04

Ubuntu 18.04 ships with PHP 7.2 as default PHP version.The latest PHP 7.4 version is officially released on November 28th, 2019.This latest version adds several new features.

Step 1: Add PPA repository

Run below commands to add repository 

sudo apt-get update
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update

once repository is added,you can install php using apt.

We hope you are following "How to Install PHP 7.4 on Ubuntu 18 04" step by step carefully. The remaining steps will help you to finish the upgrade process..

Step 2: Install php 7.4

root@ubuntu18:~# apt install php7.4
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libapache2-mod-php7.4 libpcre2-8-0 php-common php7.4-cli php7.4-common php7.4-json php7.4-opcache php7.4-readline
Suggested packages:
  php-pear
The following NEW packages will be installed:
  libapache2-mod-php7.4 libpcre2-8-0 php-common php7.4 php7.4-cli php7.4-common php7.4-json php7.4-opcache php7.4-readline
0 upgraded, 9 newly installed, 0 to remove and 64 not upgraded.
Need to get 4,193 kB of archives.
After this operation, 18.1 MB of additional disk space will be used.
Do you want to continue? [Y/n]

press 'y' to install those all packages.

Now you can check php version like below

Also Read -> How to Install PHP 7.4 on Centos 8

root@ubuntu18:~# php -v
PHP 7.4.2 (cli) (built: Jan 23 2020 11:21:30) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.2, Copyright (c), by Zend Technologies

you can check installed packages with following command

root@ubuntu18:~# apt list --installed | grep php

you can search for any additional php modules by using below command

root@ubuntu18:~# apt-cache search php7.4*

if you need additional packages install them as per your requirement

root@ubuntu18:~# apt install php7.4-gd php7.4-cli php7.4-mysql php7.4-xml php7.4-pgsql php7.4-soap php7.4-bcmath php7.4-curl php7.4-imap

Also Read -> Install PhpMyAdmin on centos 7

For Debian9/10:

First we need to install below repository 

sudo apt install -y apt-transport-https lsb-release ca-certificates wget
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
sudo apt update

Now you can install php7.4 

apt install php7.4

Also Read -> How to Install PHP Composer on Ubuntu 20 04 and 18 04

 



Warning! This site uses cookies
By continuing to browse the site, you are agreeing to our use of cookies. Read our terms and privacy policy