Install PHP 7.4 on Ubuntu

Finally PHP 7.4 is out! You have read about the new features, you have followed externals, you have gathered ideas on how new capabilities will save time. Let's get it running.

What's new?

There are countless articles about the changes php7.4 brings. Feel free to get an overview here.


Regardless of whether you want to upgrade or install, let's first adhere to the general recommendation you will find anywhere. Namely, make sure we are up to date: sudo apt-get update.

Then, we want to add Ondrej Sury's repository:

sudo apt -y install software-properties-commonsudo add-apt-repository ppa:ondrej/phpsudo apt-get update

Now we are ready to install php 7.4.

sudo apt -y install php7.4

You might want to test the success with php -v, which will give you an output about the version.


I don't know which extensions you might need, but the format is very intuitive and with the example of mbstring looks like this:

sudo apt-get install php7.4-mbstring

Tip: you can install multiple extensions with the following format:

sudo apt-get install -y php7.4-{mbstring,mysql}

NOTE: We are happy with the shipped Apache here, but be sure to install php7.4-fpm if you are aiming for NGINX after stopping apache sudo systemctl disable --now apache2

Old installations

In the case of former installations, you will want to purge the old version of php (assuming php 7.3):

sudo apt purge php7.3 libapache2-mod-php7.3


author image



Readers: {{metrics.unique}}

Total visits: {{}}