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
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).
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.
We also need to upgrade our WinCache version for PHP 7.2. Download the WinCache php_wincache-126.96.36.199-7.2-nts-vc15-x64 and extract the file as well.
Extract both downloaded zip files (just double-click them and they will be extracted into their sub-folders) as shown below:
If you check the WinCache folder php_wincache-188.8.131.52-7.2-nts-vc15-x64, look for two files with the following names: php_wincache.dll and php_wincache.pdb.
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).
Now, copy the whole content of php_wincache-184.108.40.206-7.2-nts-vc15-x64 folder into a new folder and name it v7.2.
Copy the php.ini file from v7.1 to v7.2.
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.
The change is pretty simple and we can compare the two php.ini files between v7.1 and v7.2 as below:
Open IIS Manager and click on FastCGI Settings.
Once completed, just click OK.
Go back to IIS Manager and click on Handler Mappings.
Look for PHP_via_FastCGI and double-click on it. Make sure the path for the Executable is updated accordingly. Click OK when done.
Update Windows Environment Variables
Finally, once again we need to update the path of the new PHP in Windows Environment Variables.
Click on the Windows start button and type in “system” and click on System Control panel.
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.
Click on Environment Variables… button.
Under System Variables, click on Path and Edit… button.
Click on where the current PHP is located and double-click it or click on Edit button.
Change the value to the location of the new PHP (i.e., C:\Program Files\PHP\v7.2)
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:
How to Install PHP on Windows 10 Using Web Platform Installer
Difference between PHP thread safe and non thread safe binaries
Using FastCGI to Host PHP Applications on IIS 7
WinCache Extension for PHP