Installing PHP / IIS 7 on Windows 7

alt="Internet Information Services Welcome Screen"

1. Install Internet Information Services (IIS) by selecting Start, Control Panel, Programs, Turn Windows features on or off.

Click the plus sign (+) to expand `Internet Information Services`, `World Wide Web Services` and `Application Development Features`. Under `Application Development Features`, make sure `NET Extensibility`, `ASP.NET`, `CGI, ISAPI Extensions`, `ISAPI Filters` and `Server-Side Includes` are selected.
  1. Download PHP compressed files. Note that Non-thread-safe build of PHP is recommended when using IIS.

  2. Extract the contents of compressed file to the hard disk. I this case I will extract to C:\php

  3. Rename the file c:\php\php.ini-productionto C:\php\php.ini and open it with a text editor.

  4. Configure the CGI- and FastCGI-specific settings by un-commenting the following variables

    • fastcgi.impersonate = 1
    • fastcgi.logging = 0
    • cgi.fix_pathinfo = 1
    • cgi.force_redirect = 0
  5. Set directory for the loadable extensions. Find the ;extension_dir =”ext” parameter. Uncomment it by removing the semi-colon (;) and set its value to the directory where you extracted files in step 3 followed by \ext. In my case the extensions folder will be C:\php\ext. Save the file and exit the editor.

  6. Include PHP in PATH environmental variable using the following steps:

    • Click on Start, Control Panel, System and Security
    • Click on System, Advanced system settings
    • Under Advanced tab, click on Environmental Variables
    • Under System Variables, select Path and click on Edit
    • Click at the end of the Variable value and type a semicolon followed by the location where you extracted the files in step 2. (; c:\php).
    • Click on OK until you’ve exited the System Properties window.
  7. Open IIS Manager from the Start menu

    • Click Start, and then click Control Panel.
    • Click System and Security, and then click Administrative Tools.
    • Double-click Internet Information Services (IIS) Manager.

    A quicker way of opening the IIS Manager is by clicking on Start and typing inetmgr in the Start Search box and then pressing the ENTER key.

  8. Double-click on Handler Mappings icon.

  9. From the Actions panel, click on Add Module Mapping…

    • Under Request Path type *.php
    • Under Module select FastCgiModule. If FastCgiModule is missing on the list, then you must have missed selecting CGI during installation of IIS in step 1.
    • Under Executable type navigate to the location where you extracted PHP and select php-cgi.exe or just type the location plus php-cgi.exe. (C:\php\php-cgi.exe)
    • Under Name type PHP-FastCGIand click OK.
    • Click on Request Restrictions... and select Invoke handler only if request is mapped to:
    • Select File or Folder option and click OK.
    • Click OK on the Add Module Mapping dialog and answer Yes to the dialog that appears.
  10. Set index.php as a default document in IIS.

    • Click on the Home icon to return to the IIS Manager main screen
    • Double click on the Default Document icon
    • From the Actions panel, click on Add
    • Under Name type index.php and click OK
  11. Testing the PHP installation

    • Create a simple index.php file with a single line: <?php phpinfo();?> and save it in C:\inetpub\wwwroot folder
    • Open your browser and enter (http://localhost/) and this should display information of the php installation.
    • Delete index.php from your web root folder