Articles
Installing PHP 5 on IIS in 5 simple steps
Set the PHP Application Mapping in IIS
Before IIS will parse PHP scripts, you must first create an application mapping for PHP. This application mapping basically tells IIS what ISAPI dll, or CGI executable to use to process files of a certain file extension (in this case .php). There are two ways in which we can do this, via the command line or via the IIS MMC snap in. I'm going to show you how to do both.
As this is a universal PHP installation guide for IIS 5.0, 5.1 and 6.0 there are limited universal ways in which to add the PHP application mapping via the command line. What ever you do though do not use the adsutil.vbs script to try and add you PHP application mapping, at least not without understanding it's limitations. When you add/delete an application mapping with adsutil.vbs there is no way you can add/delete a single item at a time. So by using adsutil.vbs to add an application mapping you will effectively delete every other mapping at that level. However, what you can do is use David Wang's awesome chglist.vbs script to add the PHP application mapping without effecting existing mappings. You can download this script from David's old blog or from the bottom of this page. Once you have saved the script, simply open a command window and change into the directory that contains your script and type this in;
chglist.vbs W3SVC/ScriptMaps "" ".php,D:\PHP\php5isapi.dll,5" /INSERT /COMMIT
This will add the PHP ISAPI script map to the root of the IIS metabase, and any sites created after adding this script will automatically inherit it. If you want to add the PHP application mapping to a specific website then you will need to modify the W3SVC/ScriptMaps section of the command to suite. If none of this makes sense at all, don't worry because all this can be done using the GUI as well which we will cover now.
- Open the IIS MMC and right click on the Web Sites container (or click on any specific website you wish to add PHP to) and select the properties menu item
- Once the Web Sites Properties window opens select the Home Directory tab and click the Configuration button as shown below in figure 7.
- This will bring you to the Application Configuration window. Click the Add button at the bottom to add the PHP application mapping as shown below in figure 8.
- In the Extension field enter .php and then click on the browse button in the top right and select the php5isapi.dll file from inside you PHP installation directory (e.g D:\PHP). The default is to accept all verbs, but if you wish you can limit the verbs to tighten security for you PHP application mapping. Ensure that the Script engine and Check that file exists options as ticked and then press ok until you exit the properties windows.
That is it, IIS should now be configured to serve PHP content. There is one exception though and that is if you are using IIS 6 then you will also need to configure a Web Extension, so if you are using IIS 5.0 or 5.1 you can proceed onto the next section. You can set the Web extension via command line using iisext.vbs or via the Gui. Using the iisext.vbs at the command prompt you'll need to type in this, but be sure to change the path to php5isapi.dll to suit your environment ;
iisext.vbs /AddFile D:\php\php5isapi.dll 1 PHP5ISAPI 1 "PHP 5 ISAPI"
To add the extension via the GUI, read on;
- Open the IIS MMC and expand the server tree. Right click on the Web Service Extensions option and select the Add a new Web service extension option.
- In the Extension name field put in a descriptive name, such as PHP 5 ISAPI as shown below in figure 11. Make sure the Set extension status to Allowed option is checked and then click the Add button.
- In the Add file window click the Browse button and navigate to your PHP installation directory and select the php5isapi.dll file as shown below in figure 12. Then click the ok button until you exit back into the IIS MMC.
All done, now your IIS 6 web server is all set to serve PHP content.
- Add new comment
- 737091 reads






Comments
Great Job
I have installed PHP on several different servers over the past 7 years...and these instructions were the easiest to follow without incident. My installation included PHP 5.2.9 using fastCGI, IIS 6.0, Windows 2003 Server.
Thanks
Thank you!
All my automatic installation attempts failed miserably. Your manual instructions were perfect and worked first time. The only place I deviated from your path was that in 5.2.9 PECL is not a separate entity, the extensions are all in the main php5.2.9 zip.
Not only is it working now, I also have a better idea of how the thing fits into my IIS. Very grateful.
Many thanks
Was looking for PHP5 and IIS 5.0 setup tutorial...and I found this. Worked like a charm :)
I get a blank screen when i
I get a blank screen when i access .php file
containing this
<?phpphpinfo();
?>
Any suggestions
Abhishek
PHP Guide
In the "Home Directory" tab of IIS>Web Site Properties, when I click the "Configuration" button, nothing happens???
Thanks,
Wayne
wolfz1026@gmail.com
Are you logged on as an
Are you logged on as an administrator? What version of IIS are you using?
----------------
Dominic Ryan
4 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster
Still not working ...
Have followed your instructions, I think, to the letter. The first time I tried I got the Configuration button to work but the "
<?phpphpinfo();
?>
<?phpphpinfo();
?>
<?phpphpinfo();
?>
Thanks,
Wayne
Sounds like a metabase
Sounds like a metabase issue. Try uninstalling IIS, and then delete the C:\WINDOWS\system32\inetsrv directory before reinstalling. I don't think this is a PHP setup issue, so if you could post future questions in the forums I'd appreciate it.
----------------
Dominic Ryan
4 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster
Installing PHP 5 on IIS in 5
Brian;
I apologize, I will try the forums.
I have been trying to get PHP up and running on my computer for a while now, which is how I found your guide. I have followed several guides, including yours. When done, every indication is that it is not working. The nunber one indicator is that when I run the php info script I either get a blank screen ( as the guy above ) or it displays the script line as text. I have tried uninstalling and reinstalling everything many times ... no luck.
Thanks for listening,
Wayne
Finally working, well sort of...
First off, great step by step on installing this. I had installed previous versions with zero problems and it literally took less than 5 minutes. You can imagine my surprise when I install tonight ready to do some work and here it is 2 1/2 hours later. Anyway to the point, I now have php installed and working however only in the root directory; http://localhost
Whenever I try to create a virtual directory it always prompts me to download the file. When I try to view the php info file, I get the "No Input File Specified". Do you have any idea why this is happening? I looked in all of the settings for the virtual directory and it all seems setup correctly.
Any thoughts?
-bradj