SOLVED How-To: Customize the PHP Version Warning your WordPress users see

sneader

Well-Known Member
Aug 21, 2003
1,195
68
178
La Crosse, WI
cPanel Access Level
Root Administrator
Starting with WordPress 5.1, WordPress is posting a warning in the WordPress Dashboard, if the site is using PHP version 5.5 or older. Eventually, WordPress plans to drop support for older PHP versions altogether.

The warning that customers see in the dashboard looks something like this:



Notice the big blue button that says "Learn more about updating PHP" ? By default, that button will take the user to this page:

Get a faster, more secure website: update your PHP today | WordPress.org

If you are using CloudLinux, they are (somehow) injecting their own page into this link, so it takes users to this page, instead:

CloudLinux - Main | New template

I do not like the CloudLinux page, since it basically tells users "Hey, it's Ok that you are running a crappy old version of PHP, since we have applied security patches to it." -- while it's true that the old versions of PHP are more secure with their Hardening... WordPress still won't work with these old versions of PHP eventually, so it sends the wrong message. We need to get customers to upgrade to a newer version of PHP, right? This page doesn't help.

I found out that web hosting providers can inject their own URL, so that when people click "Learn more about updating PHP", hosting providers can send users directly to their own Knowledge Base article, which might explain how to use the PHP Configuration feature in cPanel to change PHP versions (or on CloudLinux, how to use Select PHP Version). This makes much more sense, right?

So, this is how I did it... I hope it helps others to do the same:

STEP 1 - Check for mod_env and install via EA4 if necessary:
Check to see if you have the mod_env Apache Module enabled. From command line, issue the command "apachectl -M | grep env" and look to see if you have "env_module (shared)" -- if yes, proceed to step 2. If not, you need to install it. Please note that you may see "setenvif_module" but that is NOT the same. You need "env_module"

To install mod_env, go to WHM > EasyApache 4 > Apache Modules and search for mod_env. If it is toggled off, then just toggle it ON, click Next and follow the normal steps to provision.

STEP 2 - Add the special Apache Environment Variable via Include Editor
We need to add the special environment variable that WordPress is looking for, which is called WP_UPDATE_PHP_URL. We'll do this via the Apache Include Editor in WHM:

Go to WHM > Service Configuration > Apache Configuration > Include Editor, and under Pre VirtualHost Include > All Versions, simply add this one line:

Code:
SetEnv WP_UPDATE_PHP_URL "https://example.com/your-kb-article.php"
Obviously, you have to change the example.com URL with your own real link to your KB article. Hit Update, then follow the prompts to restart Apache.

That's it. Now, if you open a WP site that is using old PHP and see the warning in the Dashboard, it should take you to your own KB article, when you click the Learn More button.

NOTE: If you have servers that are used by Resellers, you might want to link to a generic page. In our case, since we use CloudLinux, I linked to the CloudLinux page that explains how to use PHP Selector. In this way, the end users get a non-branded page that still explains what they need to do.

I hope this helps someone. I wish I had this when I started on this venture. Kudos to my friends Lucas R. and Bob L. for their assistance on sorting this out as well.

- Scott
 
Last edited:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,258
463
Hello Scott,

Thanks for sharing! I've moved this over to our EasyApache forum for better visibility.