PHP Manual Upgrade

By | April 28, 2019

Manually update PHP on Windows:

  1. In the root of one of the sites create “about.php” and add: <?php phpinfo(); ?>
  2. Navigate to the file in your browser and confirm the current php version before the update.
  3. Download and extract the current version of PHP from here and extract it to C:\PHP\VerNo.\
  4. In the new directory locate php.ini-production, copy and rename it php.ini in the same location.
  5. Open the current php.ini in (path is visable here: IIS>Fast CGI Settings) > Copy the bottom portion begining with: [WebPIChanges] to end > add it to the botom of the php.ini file created in step two.
  6. Download WinCache Extension from here or here and extract it to C:\PHP\VerNo.\ext\
  7. Open a text editor and update the version number in the script below (7.3.4) then run it in CMD
REM Clear current PHP handlers
%windir%\system32\inetsrv\appcmd.exe clear config /section:system.webServer/fastCGI
%windir%\system32\inetsrv\appcmd.exe set config /section:system.webServer/handlers /-[name='PHP_via_FastCGI']

REM Set up the PHP handler
%windir%\system32\inetsrv\appcmd.exe set config /section:system.webServer/fastCGI /+[fullPath='C:\PHP\7.3.4\php-cgi.exe']
%windir%\system32\inetsrv\appcmd.exe set config /section:system.webServer/handlers /+[name='PHP_via_FastCGI',path='*.php',verb='*',modules='FastCgiModule',scriptProcessor='C:\PHP\7.3.4\php-cgi.exe',resourceType='Unspecified']
%windir%\system32\inetsrv\appcmd.exe set config /section:system.webServer/handlers /accessPolicy:Read,Script

REM Configure FastCGI Variables
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /[fullPath='C:\PHP\7.3.4\php-cgi.exe'].instanceMaxRequests:10000
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='C:\PHP\7.3.4\php-cgi.exe'].environmentVariables.[name='PHP_FCGI_MAX_REQUESTS',value='10000']"
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='C:\PHP\7.3.4\php-cgi.exe'].environmentVariables.[name='PHPRC',value='C:\PHP\7.3.4\php.ini']"

Verify the update is complete by refreshing the about.php from step two & checking all the sites. To role back to the previous version you can restore the path in the script above and run it.