1. Download PHP
You will need the VC11 x64 non thread safe version in the ZIP format. (For 64 bit windows )
You will need the VC11 x86 non thread safe version in the ZIP format. (For 32 bit windows )
Note Non Thread Safe is for IIS and thread safe for Apache
[* Note x64 is for testing.not working well.use 32bit php mean VC11 x86 non thread safe ..so if your server/pc 64 bit no problem to use VC11 x86 non thread safe. ]
2. Unpack PHP
Once you have downloaded PHP, un-zip the package to a location of your choice.
The recommended location is c:\php\
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.
– When the page loads click download, and then select the filename with x86 in it,(FOR 32bit) then click next.
– When the page loads click download, and then select the filename with x64 in it,(For 64bit) then click next.
– Run the installer and follow the on screen instructions..
[* Note in 64 bit c++ not work fine. Install both x86 and x64 C++. ]
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.
– Click Next and then Install
– 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.
– 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.
7. Configure php.ini
Before test we need to configure the php.ini file.
Rename php-production file to php.ini
Open the ‘php.ini’ file in Notepad and configure it as needed. There are a few changes you will need to make to configure PHP for your IIS 7 system:
- Uncomment and set the key, cgi.force_redirect = 0
- Uncomment the key, fastcgi.impersonate = 1
- Uncomment and set the key, extension_dir to the ‘ext’ folder in the path PHP was extracted to Example : extension_dir = "C:\php\ext"
- if need Set the key, date.timezone to the time zone of your server (the URL on the line above this key lists the accepted values).
8. 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:
Important Note
There's a fairly good chance you're missing the correct VC++ runtime for the version of PHP you're running.
If you're running PHP 5.5.x you need to ensure the VC++11 runtime is installed:
Make sure you download and install the x86 version (vcredist_x86.exe
), PHP on Windows isn't 64 bit yet.
Check If need to display error
http://www.iis.net/learn/application-frameworks/install-and-configure-php-on-iis/improve-php-error-messages-in-iis-7-and-above