Question

I updated PHP but Wordpress doesn't recognize it

Posted April 3, 2020 461 views
PHP

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 (7.0.33-26+ubuntu16.04.1+deb.sury.org+1)

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.

×
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

/usr/bin/php

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

Regards,
KDSys

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
    

    Regards,
    KDSys

    • 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
        

        Regards,
        KDSys

        • Thanks, first one worked, but wp says: Running PHP version: 7.3.16-1+ubuntu16.04.1+deb.sury.org+1 (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
            

            Or

            whereis  php
            

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

            Regards,
            KDSys

Submit an Answer