Question

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

Posted July 20, 2021 94 views
NginxPHPUbuntu 18.04

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?

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.

×
Submit an Answer
1 answer

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

  • nginx -t

Restart the web server

  • sudo service nginx restart

Hope that this helps!
Regards,
Alex