Report this

What is the reason for this report?

How to Upgrade php 7.2 to php 7.4 on Ubuntu 18.04 (nginx)

Posted on July 20, 2021

Hi everyone,

I keep seeing this message on my WordPress dashboard. Your site is running an insecure version of PHP (7.2.24-0ubuntu0.18.04.8), which should be updated.

Can you please tell me how can I upgrade my PHP to the latest version on the Nginx server?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hello, @quirkymalcom

The first important thing to know is that you won’t be actually upgrading the PHP version but installing the newest one as well.

You’ll need to add the proper repositories

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

Next depending on your WebService - Nginx/Apache you have different steps.

Let’s start with the Nginx requirements:

sudo apt install php7.4-fpm

To check this afterwards run

php-fpm7.4 -v

Now that you have the PHP version, you’ll need to install some extensions. You can do it like so

sudo apt install php7.34-extension_name

The most common extensions can be installed with the following command

sudo apt install php7.4-common php7.4-mysql php7.4-xml php7.4-xmlrpc php7.4-curl php7.4-gd php7.4-imagick php7.4-cli php7.4-dev php7.4-imap php7.4-mbstring php7.4-opcache php7.4-soap php7.4-zip php7.4-intl -y

Now you should have PHP 7.4 installed. You need to also restart Nginx in order to apply the changes.

Run the configuration test

  1. nginx -t

Restart the web server

  1. sudo service nginx restart

Hope that this helps! Regards, Alex

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.