Installing PHP on IIS is fairly straight forward using Microsoft’s Web Platform Installer. Unfortuantely numerous resources available on the web as well as the Web Platform Installer’s prerequisite check overlook a few prerequisites when installing PHP on IIS running on Windows Server. I’ve developed a guide and a list of requirements that will make the process of installing PHP on IIS much easier.
Install all available updates via Windows Update before continuing. There have been multiple updates in the past that have affected specific components from smoothly installing, specifically .NET Framework. Save yourself the trouble now and install all updates before continuing.
The first thing you should do is add the IIS role with FastCGI support. More information on installing IIS and FastCGI can be found on the official PHP website but I’ll cover the basics here.
.NET Framework 3.5 is required for the PHP Manager for IIS application which will install by default when using the Web Platform Installer to install PHP. If you don’t have .NET Framework 3.5 installed on the server, PHP will still install but you’ll be presented with an error regarding PHP Manager – it’s safe to ignore if you don’t need it. With that said, the PHP Manager application can come in handy and I recommend installing it by completing this simple prerequisite.
Although .NET Framework 3.5 can be installed using the Add Roles and Features wizard on Server, it still requires the Windows Server installation media when installing the feature. Before you proceed, obtain the Windows Server installation media and attach it to the server either by physical media or mounting the ISO.
The Visual C++ Redistributable is required when installing a default installation of PHP. It will install DLL files that are required by numerous PHP extensions. Without it you will receive HTTP 500 errors and PHP will throw the error “The FastCGI process exited unexpectedly”.
You can download the Visual C++ Redistributable from here. Be sure to grab the 32-bit version (VSU_4\vcredist_x86.exe) as the 64-bit version will not work (or maybe it’s not required?).
The Web Platform Installer is a small utility by Microsoft which is supposed to make it quicker and easier to deploy web services and deployment tools. But honestly it falls short of expectations. For example, when installing PHP it does not perform a prerequisites check for CGI, .NET Framework 3.5, or the required DLL files (installed by Visual C++ Redistributable). As long as these prerequisites are installed, PHP and the PHP Manager should install successfully.
You can download the Web Platform Installer from here. After the WPI is installed, it will automatically launch. Close it for now.
Once you’ve installed all the prerequisites you can go ahead and install PHP using the Web Platform Installer.
Congratulations. You now have a working IIS Server running PHP meeting all requirements of a default PHP installation. Enjoy!
I’ve had trouble getting PHP Manager to install on Windows Server 2019. I’ve had much better success with PHP Manager 2. It can be downloaded from here, https://github.com/phpmanager/phpmanager/releases.
Create a PHP test file, C:\inetpub\wwwroot\test.php. The contents of the file should include the following:
<?php phpinfo(); ?>
Browse to http://localhost/test.php to see if PHP is loaded and working. If not, try running the script from the command prompt. For example:
"C:\Program Files (x86)\PHP\v5.6\php-cgi.exe" C:\inetpub\wwwroot\test.php
Review and research any errors. I hope this helps!