PHP 5.3.3 with IIS7.5 on Windows 7

In previous versions of Windows with IIS installed, the installation of PHP could be difficult. Instructions were inconsistant and there were too many variables that could have gone wrong. The installation woes of IIS seem to be a thing of the past. In one rare instance, using an article, titled Installing PHP on Windows 7, that was found in a quick internet search, I was able to install and test PHP on the first attempt. Of course, there were a couple minor tweaks, but a well written article.

Install PHP

  • Download PHP 5.3.3 VC9 Non Thread Safe (filename: php-5.3.3-nts-Win32-VC9-x86.zip)
  • Unpack the content of the zip archive into a folder of your choice, for example C:\PHP\
  • Copy the C:\PHP\php.ini-production to C:\PHP\php.ini
  • Open the php.ini,search for the following lines, uncomment them and make sure they look like these below.

     extension_dir = "C:\PHP\ext"
    error_log="C:\inetpub\temp\php-errors.log" cgi.force_redirect = 0
    fastcgi.impersonate = 1
    fastcgi.logging = 0
    cgi.fix_pathinfo=1
    

Install IIS
Available in all versions of Microsoft Windows 7.

  • Click Start and then click Control Panel.
  • In Control Panel, click Programs and then click Turn Windows features on or off.
  • In the Windows Features dialog box, click Internet Information Services.
  • Click on the plus sign to expand Internet Information Services.
  • Click on the plus sign to expand World Wide Web Services.
  • Click on the plus sign to expand Application Development Features.
  • Put a check in the box to select CGI.
  • Click OK.

Configure IIS

  • Click Start and in the Search Program and Files box type inetmgr then press Enter to open the Internet Information Services (IIS) Manager.
  • From the Connections column, navigate to Sites and then Default Web Site.
  • From the Default Web Site Home column, double-click on Handler Mappings.
  • In the Add Module Mapping dialog box, add the following:
    • Request Path: *.php
    • Module: FastCgiModule
    • Executable (optional): C:\php\php-cgi.exe
    • Name: PHP
  • Press OK.
  • In the Add Module Mapping dialog box, press Yes.

Test PHP

  • Create an ASCII file with a name like phpinfo.php and put the following in it.
    <?php phpinfo() ?>
    
  • Save the file in the default IIS root folder c:\inetpub\wwwroot.
  • In a web browser, use http://localhost/phpinfo.php to test the installation.

Firewall
By default, you cannot access the IIS installation from another computer because of the firewall. To enable access, follow these steps.

  • Click Start and in the Search Program and Files box begin to type Allow a program
  • Select the result Allow a program through Windows Firewall.
  • In the Allow programs to communicate through Windows Firewall window, click the Change settings box.
  • Scroll to the bottom, and place a check next to World Wide Web Services (HTTP). This will automatically place another check in the Domain column. Also place another check in the Home/Work (private) if that is desired.
  • Click OK