IT Nota

  • Home
  • How To
  • .NET
  • WordPress
  • Contact
You are here: Home / How To / How to Upgrade to PHP 7.2 on IIS (Windows 10)

How to Upgrade to PHP 7.2 on IIS (Windows 10)

This tutorial is a shorter version of the previous post upgrading to PHP 7.1 on Windows 10 and it is intended as a follow-up on how to upgrade your PHP to the latest version (in this case PHP 7.2) if you have already installed the previous version of PHP 7 in your Windows system.

Steps to Upgrade from PHP 7.1 to PHP 7.2

  1. Download PHP for Windows. Since we’re using PHP as FastCGI, we’ll use the 64-bit Non-Thread Safe (NTS) version (i.e., php-7.2.1-nts-Win32-VC15-x64.zip).

  2. PHP 7.2 is also the first version that requires Visual C++ Redistributable for Visual Studio 2017. If you don’t have it installed, you can download it from here (64-bit). If you have a 32-bit OS, please check on the download section below and select the one for x86.

  3. We also need to upgrade our WinCache version for PHP 7.2. Download the WinCache php_wincache-2.0.0.8-7.2-nts-vc15-x64 and extract the file as well.

    WinCache Binary for PHP 7.2

  4. Extract both downloaded zip files (just double-click them and they will be extracted into their sub-folders) as shown below:

    PHP 7.2 and WinCache zip files extracted to sub-folders

  5. If you check the WinCache folder php_wincache-2.0.0.8-7.2-nts-vc15-x64, look for two files with the following names: php_wincache.dll and php_wincache.pdb.

  6. Copy the two files from the WinCache folder to a sub-folder (“ext”) within the PHP folder (i.e., php-7.2.1-nts-Win32-VC15-x64/ext).

    Copy php_wincache files from WinCache folder to ext sub-folder under PHP folder

  7. Now, copy the whole content of php_wincache-2.0.0.8-7.2-nts-vc15-x64 folder into a new folder and name it v7.2.

    Copy all PHP files to a new folder v7.2

  8. Copy the php.ini file from v7.1 to v7.2.

  9. You might want to modify certain parameters in the php.ini as highlighted below:

    [WebPIChanges]
    error_log=C:\WINDOWS\temp\PHP72x64_errors.log
    upload_tmp_dir=C:\WINDOWS\temp
    session.save_path=C:\WINDOWS\temp
    cgi.force_redirect=0
    cgi.fix_pathinfo=1
    fastcgi.impersonate=1
    fastcgi.logging=0
    max_execution_time=300
    date.timezone=Australia/Melbourne
    extension_dir="C:\Program Files\PHP\v7.2\ext\"
    

    And make sure you also have the PHP_WINCACHE set.

    [PHP_WINCACHE]
    extension=php_wincache.dll
    

    The change is pretty simple and we can compare the two php.ini files between v7.1 and v7.2 as below:

    Compare php.ini files between v7.1 and v7.2

  10. Open IIS Manager and click on FastCGI Settings.

    IIS Manager FastCGI Settings

  11. You can create a new entry for PHP 7.2 by following Step 8 from previous post, except for PHPRC where you want to update the value to 7.2 (i.e., C:\Program Files\PHP\v7.2).

    Once completed, just click OK.

    IIS Manager FastCGI Settings Modify PHPRC to version 7.2

  12. Go back to IIS Manager and click on Handler Mappings.

    IIS Manager Handler Mappings

  13. Look for PHP_via_FastCGI and double-click on it. Make sure the path for the Executable is updated accordingly. Click OK when done.

    IIS Manager Handler Mappings PHP_via_FastCGI set to v7.2

Update Windows Environment Variables

Finally, once again we need to update the path of the new PHP in Windows Environment Variables.

  1. Click on the Windows start button and type in “system” and click on System Control panel.

    Windows System Control Panel

  2. In System window, click on Advanced system settings and on System Properties window, make sure you have Advanced tab opened. And you can follow the path shown in the picture to update the path to where your PHP 7.2 is located.

    Control Panel System Environment Variables Update to PHP 7.2

  3. Click on Environment Variables… button.

  4. Under System Variables, click on Path and Edit… button.

  5. Click on where the current PHP is located and double-click it or click on Edit button.

  6. Change the value to the location of the new PHP (i.e., C:\Program Files\PHP\v7.2)

  7. Click OK button on each window to close.

That’s it! Now using the same test.php file with the following code:

<?php phpinfo(); ?>

Run it from your browser (i.e., http://localhost/test.php). If PHP is installed with the correct version, you will see the PHP version will be updated similar to the picture below:

phpinfo 7.2.1 displayed on a page

Further Reading

How to Install PHP on Windows 10 Using Web Platform Installer
FastCGI
Difference between PHP thread safe and non thread safe binaries
Using FastCGI to Host PHP Applications on IIS 7
WinCache Extension for PHP

Download

Download PHP For Windows: Binaries and sources Releases
WinCache 2.0.0.8 PHP Extension Direct Download
Microsoft Visual C++ Redistributable for Visual Studio 2017

January 19, 2018 Filed Under: How To Tagged With: IIS, Internet Information Services, Microsoft, PHP, Windows, Windows 10

Buy me a coffee?

Buy me a coffee If you find any of the articles or demos helpful, please consider supporting my work here, you'll have my big thanks!

Comments

  1. Rob says

    February 3, 2021 at 9:53 am

    Hi,

    This might be a daft question, but if the current version is in directory say c:\PHP can I just save the php.ini to another location, delete the old version file then copy the new ones in and add the php.ini back? That would save having to go into IIS and change the various paths? Or am I being too simplistic?

    Reply
  2. Nika says

    December 23, 2020 at 11:21 am

    Thanks

    Reply
  3. Richard S. says

    April 19, 2020 at 12:37 pm

    Everything was good, I just need to add that I was installing the version 7.4.5 which is the last one as of right now, and the only issue I found was that I needed to Install C++ Redistributable Package 2019. After it, everything was really good.

    Reply
    • platt says

      April 20, 2020 at 12:50 pm

      Thanks for your comment Richard. It’s also good for other readers to note that it’s better to install the newer version of C++ Redistributable Package and PHP since the principle should be the same. Just make sure you test it first before production use.

      Reply
  4. ED says

    September 28, 2018 at 11:24 am

    One thing to add — this is the first major release of PHP from windows.php.net that requires the 2017 C++ Distributable, so make sure that’s installed as well. (This is the “VC15” in php-7.2.1-nts-Win32-VC15-x64.zip.)

    Reply
    • platt says

      September 29, 2018 at 3:14 pm

      A lot of times this part is taken for granted because it got installed with Visual Studio 2017. I added this point to the guide. Thanks for mentioning this Ed.

      Reply
  5. Abe says

    August 12, 2018 at 7:41 am

    Much appreciated..thank you

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Buy me a coffee Support this site
Buy Me a Coffee?

Categories

  • .NET
  • Coding
  • Cybersecurity
  • Database
  • How To
  • Internet
  • Multimedia
  • Photography
  • Programming
  • Resources
  • Review
  • Tips and Tricks
  • Use Case
  • WordPress
  • Writing

Recent Posts

  • How to Delay Shutdown or Restart on a Mac
  • How to Activate Built-in Web Server
  • SSIS Best Practice with Naming Conventions
  • How to Delay Shutdown or Restart on a Windows Server
  • How to Type Emoji Using Keyboard Shortcuts in Windows and macOS

Recent Posts

  • How to Delay Shutdown or Restart on a Mac
  • How to Activate Built-in Web Server
  • SSIS Best Practice with Naming Conventions
  • How to Delay Shutdown or Restart on a Windows Server
  • How to Type Emoji Using Keyboard Shortcuts in Windows and macOS

Tags

.NET ASP.NET Cdonts Dll Classic ASP Code Editor ETL FSharp Genesis Framework Git Google HP Asset Manager HTML5 Hugo IIS Information Security Internet Internet Information Services iOS JAMStack JavaScript Linux macOS Microsoft Microsoft SQL Server MVC PHP PowerShell Python Simple Mail Transfer Protocol Smtp Server SQL SQL Server SSIS SSMS SSRS Sublime Text Visual Studio Visual Studio Code VPN Web Server Windows Windows 8 Windows 10 Windows 2012 Windows Server

Copyright © 2011-2023 IT Nota. All rights reserved. Terms of Use | Privacy Policy | Disclosure