There are a few simple steps you need to take in order to get PHP working under IIS 6.0
First we need to create and then enable an appropriate Web Service Extension so that IIS will both recognise and allow PHP files to be processed by the appropriate script engine.
You can use the Internet Information Services (IIS) Manager GUI method to perform this task (and most tutorials and guides you may find tend to use this method) but there is a much quicker way of doing this; namely using the ‘iisext.vbs’ Command-Line Administration Script, which you will find in C:\Windows\system32 by default.
Assuming you are using the same directory structure as I am in this walkthrough you can simply copy and paste the following line of text and execute it at a command prompt from C:\Windows\system32 :
cscript iisext.vbs /AddFile c:\PHP\php5isapi.dll 1 PHPISAPI 1 “PHP ISAPI”
As you can see, this script creates a new Web Service Extension named “PHP ISAPI” with a status of Allowed.
The IIS 6.0 Command-Line Administration Scripts are very powerful and flexible tools and I would recommend using them wherever possible. You can find out more about administering IIS from the command line here :
Administering Servers from the Command Line in IIS 6.0
You can use the default web site for test purposes if you prefer but in this example I am going to use a dedicated PHP test web site. I have created a test web site which has a home directory of C:\test. The next step is to create an Application Extension Mapping at the web site level for PHP scripts. You can perform this step using the MMC GUI but I am going to use AdsUtil.vbs for this demonstration.
There is actually a good reason for doing this – as I intend to use this web site purely for PHP testing I can remove any unused application mappings on my PHP web site, such as .idc, .shtml and .asp, etc.
I can achieve this simply by executing the following script from a command prompt at C:\Inetpub\AdminScripts :
cscript adsutil.vbs set W3SVC/87257621/root/Scriptmaps “.php,C:\PHP\php5isapi.dll,5”
Running the above command has the effect of setting the Scriptmaps metabase property for Web Site ID 87257621 so that only the .php Application Extension Mapping is enabled.
However, as you can see, this script doesn’t just add the PHP script mapping to the web site – it removes any existing mappings as well – so only use the above command if you are sure that you want to remove any existing application mappings on your chosen web site. In other words, if you run the above script against a web site which hosts any other applications (such as ASP) then it will break that site’s functionality and you will need to repair the application mappings manually. So only do this if you are sure that you only want to run PHP on your chosen web site.
#Note – if you are using your web site for development and you need to retain any existing application script mappings then you can use an excellent script provided by IIS guru David Wang which provides far greater flexibility than Adsutil.vbs. You can find David’s script here :