Update an installation of PHP on Windows

It will come as no surprise that I operate my website on Windows and WordPress so it should come as no surprise that it also uses PHP. Part of running the server using PHP requires it to be updated from time to time so after toying with the idea for ages, I’ve finally got round to writing some PowerShell to do the job for me. Typically I could download and prepare the PHP installation in about 5 minutes so my site and server wouldn’t be offline for long but I see no reason to waste 5 minutes when I can run a script and it be done in less than 30 seconds.

So here’s a PowerShell script that will automatically update your existing installation of PHP on Windows 2012 R2.

It archives your current installation of PHP (identifying it by its version), downloads the latest release, unpacks it to a directory, copies over any additional files and extensions etc. from your existing installation of PHP, stopsĀ  IIS, moves the new files and starts up IIS again. With a blank folder, it can also jsut download and unpack PHP in order to “install” it for use in debugging etc.

It’s functional for me but might need some work for your use.