Wordpress not recognizing php version

I was recently installing plugins into one of my non-primary blogs on another host and saw this message.

What the heck?

How is it possible that my version of php could be “THAT OLD”?

Well, after checking in the cpanel for the host as well as checking on my directories on my server.

The version was actually much newer than the version being reported.

Several plugins were reporting this issue. Actually a few plugins were broken it seemed due to this older version of php.

This was bad. One of the plugins I wanted to install on this installation of wordpress was actually BREAKING my wordpress installation. I had to go into WordPress and remove the plugin manually since it would take down access to even the backend of WordPress.

That’s really terribly bad…

So what was the problem?

How to check on your Server

  • SSH into your server
  • type php –version

Is the version what you expect or is it the one reported via the wordpress plugin?

So if the version is correct, what else could it be.

In my case, it was the .htaccess file in the WordPress directory.

So here’s the issue.

It seems that the normal .htaccess in my root directory was correct.

BUT there are other .htaccess file created by WordPress [or other services] that are forcing it to use a earlier version of the file.

How to Fix the php .htaccess problem

You can do various things.

1. Delete the wordpress .htaccess [rm .htaccess]

This would cause you to use the .htaccess from a higher directory. However this is probably a bad idea especially if you have plugins that are editing this .htaccess or other wordpress specific aspects of it.

2. You can add in the line for the correct .php

You can get this line from the root directory .htaccess [if its using the version you want to use].

Just copy  the line with AddHandler application/ from that file into your wordpress .htaccess file. Be sure it matches exactly though

3. You can also comment out the line for the offending php version.

To do this, edit the file and add a # in front of the line you no longer want the system to use.

However when doing this be sure that there is no other offending .htaccess in a higher directory that may still cause it to report the wrong version or a conflicting version.

* * * * *

Did it Work?

For me that was it.

After editing the .htaccess file in WordPress my installation, plugins, and all the bad reporting disappeared suddenly. I finally was able to get back to work on getting this installation and version of WordPress. Honestly I need to log into WordPress more often to make sure things are up to date.

Actually the wordpress blog was faster now after fixing the problem as it was finally using the newer / better version of .php and all that goes with that.

So lesson here? Pay attention to the error messages and make sure that you regularly check to make sure your system is as up to date as possible. Even sites you may not check on a regular basis.

Other Posts you May Like

  • Enable HTTP Strict Transport Security in WordPress
  • Security Plugins for Firefox

Viewing 11 replies - 1 through 11 [of 11 total]

  • Site health is telling you what WordPress sees. Most servers can support multiple versions of PHP. Check both the .htaccess file for your site and an php.ini files to see if they’re picking a version other than the one you just installed.

    Thread Starter hiker

    [@hikeventures]

    Thanks Steve, my .htaccess file is blank and I have also changed my php.ini. Still doesn’t work …

    You can’t have a working WP site and a blank .htaccess file! Anyhow, there’s something in your configuration that’s overriding the change you made to PHP and that occurs outside of WordPress. Tell me about your hosting.

    Thread Starter hiker

    [@hikeventures]

    I am hosting my site on Hetzner.
    When I look in FTP then I see a .htaccess file with 0kb and it’s empty. It is located in this directory: /home/hikeventures/hikeventures

    I also have nginx and there I have changed the line below with the PHP version installed:
    fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;

    directory: /etc/nginx/sites-available

    In the php.ini which is located here /etc/php/7.4/fpm I have changed different max values.

    What do you see if you try

    ps -ef |grep php ?

    What version of php is running?

    Thread Starter hiker

    [@hikeventures]

    root      1131     1  0 Mar17 ?        00:00:13 php-fpm: master process [/etc/ph                               p/7.2/fpm/php-fpm.conf]
    www-data  1413  1131  0 14:17 ?        00:00:12 php-fpm: pool www
    www-data  1536  1131  0 14:23 ?        00:00:27 php-fpm: pool www
    www-data  1649  1131  0 14:27 ?        00:00:06 php-fpm: pool www
    hikeven+  3006  2980  0 15:17 pts/0    00:00:00 grep --color=auto php
    root      9234     1  0 Mar17 ?        00:00:10 php-fpm: master process [/etc/ph                               p/7.4/fpm/php-fpm.conf]
    www-data  9259  9234  0 Mar17 ?        00:00:00 php-fpm: pool www
    www-data  9260  9234  0 Mar17 ?        00:00:00 php-fpm: pool www
    • This reply was modified 2 years, 6 months ago by Steven Stern [sterndata].

    So you have two php-fpm processes running. What happens if you stop the one from 7.2?

    sudo kill -9 1131

    This is clearly not a WP problem but a Linux admin issue.

    Thread Starter hiker

    [@hikeventures]

    Now I get an error Error 502 when I visit my site …

    OK, so something in your nginx or httpd config is referencing PHP 7.2. You’re going to have to dig through your configs in /etc [and other places] as well as in the site’s root to find out what’s doing it.

    Restart that php-fpm process to get your site working again.

    Thread Starter hiker

    [@hikeventures]

    Thanks, Steve, is there maybe a program which could trace from where this PHP 7.2 referencing comes? There are quite a lot of files …

    Linux sysadmin is not for the faint of heart! I’d ask in a support forum for your particular Linux flavor.

  • Viewing 11 replies - 1 through 11 [of 11 total]

    How do I change PHP version in WordPress?

    To update your WordPress site's PHP version, go to Sites and select the site you'd like to change the PHP version on. Then click on the Tools tab. Under PHP Engine click on the Modify button and select your preferred PHP version in the drop-down menu.

    How do I find my WordPress PHP version?

    After logging into your WordPress admin, go to Tools > Site Health > Info > Server. There you'll find the PHP version on which your WordPress site is currently running.

    Is PHP 8.0 Stable for WordPress?

    Is WordPress compatible with PHP 8? Yes, WordPress is compatible with PHP 8.0. However, only WordPress 5.6 or higher versions are compatible with PHP 8. If you are using an older WordPress version, you can upgrade it to at least 5.6 to enjoy using PHP 8.

    Do I need to update PHP for WordPress?

    Your website will be more secure. PHP, like WordPress, is maintained by its community. Because PHP is so popular, it is a target for hackers – but the latest version will have the latest security features. Older versions of PHP do not have this, so updating is essential to keep your WordPress site secure.

    Chủ Đề