How to Install PHP for Windows Internet Information Services (IIS) 🌱

What is IIS (Internet Information Services)?

Internet Information Services (IIS) for Windows® Server is a flexible, secure and manageable Web server for hosting anything on the Web. From media streaming to web applications, IIS's scalable and open architecture is ready to handle the most demanding tasks. -https://www.iis.net/

What is PHP (PHP Hypertext Preprocessor)?

A popular general-purpose scripting language that is especially suited to web development.
Fast, flexible and pragmatic, PHP powers everything from your blog to the most popular websites in the world. -https://www.php.net/

NOTE: This tutorial assumes IIS is already installed and running on the host. Check out this previous tutorial to find out how to install IIS here

  1. Log into the Windows server with an account with admin privileges
  2. Download the Non-Thread Safe (NTS) VS16 x64 PHP for Windows .zip Download
  3. Install Microsoft Visual C++
  4. Extract the downloaded PHP for Windows .zip file
  5. Rename the extracted folder PHP
  6. Cut the PHP folder to a safe location to run from, such as C:\Program Files
  7. Click the Start button > Search Control > Click Control Panel
  8. Click on System > Advanced system settings
  9. Click the Environment Variables...
  10. Edit the System Path variable
  11. Click the New button
  12. Add the PHP installation directory (ie C:\Program Files\PHP\
  13. Click OK to all open dialog windows
  14. Launch Server Manager from the Start
  15. Click Add roles and features
  16. Click Next on the Before you begin screen
  17. Select Role-based or feature-based installation > Next
  18. Leave Select a server from the server pool selected and select the current Windows server > Next
  19. Expand Web Server (IIS) > Expand Web Server > Expand Application Development > Check the box next to CGI to select it
  20. Click Next
  21. Click Next on the Select features screen
  22. Click Install on the confirmation screen
  23. Leave the installation progress screen open until the install completes
  24. Once the Feature installation completes successfully, click the Close button
  25. Back in Server Manager, click Tools > Internet Information Services (IIS) Manager
  26. Click the server name to select it > Double click Handler Mappings
  27. Click Add Module Mapping at the top right of the dialog
  28. Complete the Add Module Mapping form as follow

    Request Path: *.php
    Module: FastCGIModule
    Executable: C:\Program Files\PHP\php-cgi.exe
    Name: PHP

  29. Click OK
  30. Click Yes to confirm creating the FastCGI application
  31. Click the server name again to select it and return to the main options menu > Double click Default Document
  32. Click Add... at the top right of the dialog
  33. Type index.php > Click OK
  34. Right click on the server name > Stop
  35. Right click on the server name again > Start
  36. Expand the server name > Expand sites > Right click on Default web Site > Select Explore
  37. A File Explorer window will display the wwwroot folder for IIS
  38. Right click in the whitespace > New > Text Document > Name the new file phpinfo.php
  39. Edit phpinfo.php in Notepad and paste the following

    <?php
     phpinfo();
    ?>

  40. Save the changes to phpinfo.php and close Notepad
  41. Open a web browser and navigate to http://DNSorIP/phpinfo.php