Install PHP on Windows and IIS

8/14/2014 12:10:32 AM

The following simple tutorial is intended to help you setup PHP on a Windows machine running IIS (7.0 or higher in this example).

  1. Install IIS Including the CGI Module

    If you haven't already installed IIS, you will have to do so. If you have installed IIS but have not installed the CGI module, you must do so. Go to Start Button -> Control Panel -> Programs and Features -> Turn Windows features on or off (left hand side). Select the following features.
  2. Download PHP

    You first must download PHP to your computer. Get the latest non-thread-safe version. If installing on IIS 6 or older, you will download the thread safe version.
    http://windows.php.net/download/
  3. Install PHP

    You can install PHP wherever you like. I prefer the following path:
    C:\php\{version #}
    Extract the download PHP folder and files. The PHP files (ex: php-cgi.exe should be in the directory below).
    ex: C:\php\5.5.15-nts\php-cgi.exe
  4. Update Your IIS Hanlder Mappings to Handle .php Files

    Go into IIS and click on the server root (above Sites and Application Pools). Click the Handler Mappings icon,

    Click the Add Module Mappings link.

    Update the Add Module Mapping popup to look like the following (with your specific executable path).
  5. Create a Test Site

    To test if the installation is correct, create a new IIS site. In the root of the site, create a file named index.php. Update the file with the following content:
    		<? php phpinfo();
    
  6. Navigate to Your New PHP Page

    Now that you have a new site setup and a php page created, navigate to it. You url might look something like the following:
    http://localhost/index.php
    If everthing worked, the page should look like this.
  7. *Issues

    If you have trouble accessing your new site and page, you may need to update Windows security settings on the root directory of your site (http://www.codelocker.net/codes/30213/adding-security-permissions-to-website-folder-using-iis-7-and-the-application-pool-virtual-users/