I updated PHP but Wordpress doesn't recognize it

Posted April 3, 2020 4k views

I get this by typing php -v:

PHP 7.4.4 (cli) (built: Mar 20 2020 13:47:17) ( NTS )
Copyright © The PHP Group
Zend Engine v3.4.0, Copyright © Zend Technologies
with Zend OPcache v7.4.4, Copyright ©, by Zend Technologies

Wordpress says:

Your site is running an older version of PHP (

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
2 answers

Hi @rem3n,

Most probably you have multiple PHP versions on your droplet and your website is using another one.

What I’ll recommend doing in order to confirm this is, SSH to your droplet

ssh root@DropletIp

Go to your website’s DocumentRoot

cd /path/to/website

create an info.php file there like so

touch info.php

As soon as you have created it add the following content

<?php phpinfo();

Save the file and load it in the browser, there you should be able to see the full php PATH of our application. Most probably you are using the default one located


You’ll need to change it to use the newest PHP version you have installed by chaning the path in your vhost configuration file.


  • the default file is index.php and has this code:

     * Front to the WordPress application. This file doesn't do anything, but loads
     * wp-blog-header.php which does and tells WordPress to load the theme.
     * @package WordPress
     * Tells WordPress to load the WordPress theme and output it.
     * @var bool
    define( 'WP_USE_THEMES', true );
    /** Loads the WordPress Environment and Template */
    require __DIR__ . '/wp-blog-header.php';

    php 7.4 sits in: /etc/php/7.4/

    Can you properly edit the file to make sure Wordpress recognizes the upgraded php? Where the /etc/php/7.4/ path would go within the file’s code?

Where is the vhost configuration file located? I’ll look into this but it looks a bit complicated to me. Could you say what exactly I need to do to fix this.

  • HI @rem3n,

    Yes of course! First can you please type the following command and let me know it’s output on your droplet

    netstat -tulpen | grep 80


    • tcp6 0 0 :::80 :::* LISTEN 0 111415617 10180/apache2
      tcp6 0 0 :::443 :::* LISTEN 0 111415621 10180/apache2

      • Hi @rem3n,

        Okay so it seems you are using Apache2. In this case, you firstly try with

        a2dismod php7.0 ; a2enmod php7.4 ; service apache2 restart

        Check if your website is now using the proper version. If it isn’t, you’ll need to run the following command

        sudo update-alternatives --set php /usr/bin/php


        • Thanks, first one worked, but wp says: Running PHP version: (instead of 7.4.4 which I get by typing php -v)

          I tried second one and got this: update-alternatives: error: alternative /usr/bin/php for php not registered; not setting

          • Okay, in that case when you type the following commands

            locate php


            whereis  php

            That way, you’ll know where have you installed the different php versions.