Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

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

Discussion in 'EasyApache' started by sneader, Mar 28, 2019.

Tags:
  1. sneader

    sneader Well-Known Member

    Joined:
    Aug 21, 2003
    Messages:
    1,165
    Likes Received:
    53
    Trophy Points:
    178
    Location:
    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:

    [​IMG]

    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
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    #1 sneader, Mar 28, 2019
    Last edited: Mar 28, 2019
    cPanelMichael, SS-Maddy and laxbobber like this.
  2. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,555
    Likes Received:
    2,182
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello Scott,

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

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice