IISUnderground - A help website for setting up Microsoft IIS

Installing PHP

PHP LogoThis tutorial will guide you through setting up PHP on your IIS 7.5 server.

Time to complete: ~15 minutes

Requirements: Working installation of IIS 7.5.


1. Download PHP

You can get the PHP binaries from http://windows.php.net/download/.

You will need the VC11 x86 non thread safe version in the ZIP format.


2. Unpack PHP

Once you have downloaded PHP, un-zip the package to a location of your choice.

The recommended location is c:\php5\ but in this installation example we’ll be using d:\php5\.


3. Install the C++ Runtime

PHP is compiled using the Visual Studio Compiler so we must install the C++ Runtime in order for PHP to work.

If you do not do this step, you will get an Error 500 from the fast-cgi module and PHP will not work.

– Browse to http://windows.php.net/.

– On the left side, select the download link for Visual C++ Redistributable for Visual Studio 2012 (link working at time of posting).

– When the page loads click download, and then select the filename with x86 in it, then click next.

– Run the installer and follow the on screen instructions..


4. Install the CGI module in IIS

The CGI module is necessary for PHP to run. By default this isn’t installed so we will need to do this before we can proceed.

Depending on the version of Windows you are running the procedure is slightly different, so you will need to choose from one of the two methods below.


Windows Server 2008 and 2008 R2

Navigate to Start\Control Panel\All Control Panel Items\Administrative Tools and open Server Manager.

– In the left hand side there is a tree of services, navigate to Roles > Web Server (IIS).

– Scroll down until you see Role Services.

– Select Add Role Services.

– Find Application Delevopment and then CGI and select the tickbox.

CGI role for IIS in Windows Server 2008

– Click Next and then Install

– When it has finished, you may need to restart IIS or the computer. Do this if requested.


Windows Vista/7

– Navigate to Start\Control Panel and open Programs and Features.

– On the left select Turn Windows features on or off.

– In the tree of services, navigate to Internet Information Services\World Wide Web Services\Application Development Features and then select CGI.

CGI role for IIS in Windows7/Vista

– Click OK to start the installation.

– When it has finished, you may need to restart IIS or the computer. Do this if requested.


5. Installing PHP

We that we have the necessary roles we can now install PHP.


– Load up the IIS Manager by going to Control Panel\All Control Panel Items\Administrative Tools and opening Internet Information Services (IIS) Manager.

– In the folder tree on the left select your server, then select the site you want to add PHP to.

– In the icon view, select Handler Mappings.

– On the right, select Add Module Mapping.

– Fill out the fields as below:


Request Path: *.php

Module: FastCgiModule

Executable: d:\php5\php-cgi.exe     Remember to enter the path you un-zipped PHP to.

Name: php5     You can select any name you wish.


– Now click the button Request Restrictions…

– On the Mapping Tab click the check box and then select File.

Default Index File / Default Document

– Click OK twice and the module is now installed.


6. Adding an index file/default document for PHP

An index file/default document is the file that is first called automatically when you visit a folder. For example visiting www.iisunderground.com will automatically invoke index.php from the root folder. We need to tell IIS what we want to use as this file.


– On the left of the IIS Manager, select the site we are working on again to return to the page of icons.

– From here select Default Document.

– On the right click Add.

– In the box, enter index.php

– Click OK and the index file/default document is now added.


You can feel free to add more here later if you want to use something other than index.php as your default file.


7. Testing our installation

To make sure the install has worked, we need to create a test PHP file.

– Create a new file in the folder you have stored your websites files in.

– Name it test.php

– Inside it, put the following code:


<?php phpinfo(); ?>


– Save it and then visit the URL to test.php and you should get something like this:

An example of a PHPInfo page

If you see something similar to that then congratulations, PHP is working! If not, go back and follow each step again to see where you went wrong. If you still have problems, drop us a line on our Facebook page.


Now you need go and learn about configuring your php.ini file to secure your server from malicious attacks on your scripts.