Upgrade PHP 7 on Windows Server with WebPI

I was recently working on a Windows Server which hosts a WordPress site that had been upgraded from version 4.x to version 5.3. While reviewing the WordPress Dashboard afterwards to ensure everything was working properly I noticed the warning below about PHP being out of date.  It turns out starting with WordPress 5.1 a warning will be displayed if the server hosting your site is running any version than PHP 5.7.  The WordPress team has introduced the warning in hopes of nudging site owners into upgrading PHP because PHP 7.0.x is no longer supported with new security fixes.

image

 

I was aware that PHP 7.3 had been released in December of 2018.  PHP 7.4 would be coming in November and would be the last update until PHP 8 which is scheduled for release in Q4 2020. So this seemed like a good time to upgrade PHP on the server.  In this walkthrough I will show how to determine which version of PHP is installed on a Windows server and get how to get it updated.

 

Identifying which version of PHP is installed

In case you’re not sure what version of PHP is installed on your Windows server there are a couple ways to quickly identify it. The first way would be to open IIS Manager and click on the FastCGI Settings icon. The FastCGI Settings module will show you which versions of PHP are configured.

image

 

The 2nd option is to execute the phpinfo() command from a simple .php file locally on the server. In this example the output shows PHP 5.6.31.

image

 

Upgrading PHP Using the Web Platform Installer

Microsoft’s Web Platform Installer (WebPI) is a free tool that can be installed on any Windows server most popular open source web apps and web platform technologies such as WordPress, PHP, and MySQL just to name a few. After installing WebPI simply search for PHP and you’ll be presented with a list of PHP versions and other supporting software bits like Windows Cache Extension.  In the example below I selected PHP 7.3.7 from the catalog and upon clicking Install the installation wizard presents a notification for other Perquisites that will also be installed.

image

 

The installation will proceed after clicking I Accept and the progress will be displayed.

image

 

Once the WebPI installation completes I return to the WordPress Dashboard and now see that the PHP Upgrade warning is no longer being displayed.

image

 

Running phpinfo() command again shows that the server has now been updated to version 7.3.

image

 

IIS PHP Manager

Opening PHP Manager from within IIS Manager offers a convenient way to manage the server’s PHP configuration. Clicking the menu item to Change PHP version allows you to switch between currently installed versions. This is an easy way to set the server back to an earlier version of PHP if you experience issues with the latest version deployed. Clicking on Register new PHP version allows you to manually register a new version of PHP. You would first need to download the new version to the server and then use this feature to set the path and then click Change PHP version to switch to that new version.

Double checking the FastCGI Settings also shows which versions of PHP are configured in IIS.

image

 

Manually installing PHP on Windows Server

Installing PHP on Windows Server via the Web Platform Installer is the easiest way to get the job done however the trade off is that the Web PI catalog tends to be a version or 2 behind the latest public version of the software in question. So if you need the absolute latest version of PHP installed you will have to do to manually. Installing manually requires some additional considerations. You should consult the Manual PHP  Installation on Windows Server documentation. The Non-Thread-Safe(NTS) build is intended for IIS. Additionally when manually installing PHP 7.x on a Windows Server the latest version of Visual Studio C++ Redistributable is required.

 

Uninstalling Older Versions of PHP

After upgrading PHP on Windows to a newer version you may decide to remove previous versions. It is important to note that not all versions of PHP are backward compatible and they routinely remove deprecated functionality.  So Migrating from PHP 5.6.x to PHP 7.0.x for example may have complications. Be sure to perform extensive testing before migrating to a new version and removing a legacy version.

To remove an older version of PHP simply go back to the FastCGI Settings in IIS Manager. Right click the version in question and select Remove.

image_thumb10

 

You will be prompted to confirm you want to remove it.

image_thumb13

 

Double checking the applicationhost.config will confirm that the old version has successfully be removed from IIS.

image_thumb19

 

The old binaries will still be the Program Files (x86) so manually delete those to finish removing the old version.

 

In Summary

When upgrading to WordPress 5.x you may see warning that the version of PHP on your server is out of date. The Microsoft Web Platform Installer is a powerful tool that makes it very easy to install a wide variety of open source web applications including WordPress, MySQL, and PHP 7.3. Thanks for reading.

Peter Viola

Creative, customer focused, results oriented, Senior Web Systems Engineer who enjoys providing the highest level of customer service supporting complex Windows hosting solutions. MCITP, MCSA, MCTS

More Posts - Website