Upgrading to PHP 7.4 on Ubuntu

The anticipated PHP 7.4 version was released 28th November 2019 with a handful of new features and a slight speed improvement. Upgrading your now older PHP version can quickly and easily be done by following along this post.

This tutorial is based on an Ubuntu 18.04 server.

First step is to update repositories and add the ondrej PHP Personal Package Archive:

sudo apt-get update
sudo add-apt-repository ppa:ondrej/php

Install PHP 7.4 barebones with

sudo apt install php7.4 php7.4-common php7.4-cli

Install your PHP extensions that will be needed or used, common ones can be installed with:

sudo apt install php7.4-mysql php7.4-curl php7.4-json php7.4-gd php7.4-mbstring php7.4-intl php7.4-bcmath php7.4-bz2 php7.3-readline php7.3-zip

Apply the new PHP module to your web server, if using an Apache or Nginx webserver:

sudo apt install php7.4-fpm

Find your current installed and active version of PHP with

php -v

Or create a PHP file with


Here mine was 7.3

php info php version 7 3
PHP version 7.3

Disable the current active PHP version with

sudo a2dismod php7.3

And enable the newly installed 7.4

sudo a2enmod php7.4

Restart apache and check the phpinfo file

sudo systemctl restart apache2
php info php version 7 4
PHP version 7.4

You now have PHP 7.4 installed and active.