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
- 738080 reads






Comments
Redirecting to "Apache2-Default".
Thanks for your input, but I don't have apache installed -- not unless it's packaged in something else.
There is no Apache service running on my machine according to my services console, and just to be sure I've looked for apache files on my hard drive and found none, except those with the following installations:
1. Eclipse (ganymede and galileo)
2. PHP (the new installation)
IIS is definitely running. My machine is also set up as a ColdFusion 8 server. It's a development box and I switch between websites through IIS as needed. When I first got that strange apache behavior, I tried:
1. shutting down all ColdFusion services (there are about 5 or 6)
2. resetting IIS on the DOS command prompt
3. hitting the phpinfo.php file in the home directory I selected through the IIS console
Even after that I continue to get that behavior I described previously along with the "It Works" page.
My thinking is that if Apache is running it must be configured somewhere, so I searched the php.ini file for any loose references to apache, and only found 4, which were part of the comments.
I realize you can only be so specific through this comment UI, but can you give me a few suggestions about where I can look for evidence of some default apache instance in IIS or in the PHP installation?
Thanks again for your help.
The specified module could not be found.
Hi,
Do you have any suggestions what I can do to get around this "specified module could not be found" message?
I tried re-commenting the ";extension=php_mysql.dll" line, but I'm assuming a dll is what it means by "module". It didn't help, and besides, the mysql extension is where it ought to be.
I thought maybe it was a problem with the extension_dir path, but the path is good: extension_dir = "C:\Program Files\PHP\ext".
Thanks.
The specified module could not be found.
I found the problem. My installation was in the "Program Files" directory, and I needed to type the following for the .php extension mapping:
C:\Progra~1\PHP\php5isapi.dll
instead of:
"C:\Program Files\PHP\php5isapi.dll"
Thanks Dominic for your clear set of instructions. I will pass them on.
Check Eclipse doco
For the issue where your phpinfo() page is prompting you to download the file rather than process and render it, have a look at this guide. As for the second issue of being redirected to apache2-default, I'd suggest contacting Eclipse support. I've never used Eclipse, but redirecting to that URL is not instigated by a standard PHP install so I can only assume that it must be Eclipse from the info you have posted.
----------------
Dominic Ryan
5 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster
PHP 5.3 on IIS 5.0 Windows 2000 (or XP)
Didn't need all the 5 steps of the article.
Make sure IIS is running when you install PHP and click set up with IIS-CGI.
Once done just go into the IIS admin panel and add the .php extension and browse to the executable in the PHP program directory "php-cgi.exe % %".
Don't forget the two % symbols with spaces between!
Check PHP is in the PATH variable as described in article above.
At Last
I have been struggling to get php to work and finally a clear and easy to follow How To. Thanks for the effort.
Thanx a Lot
Brashquido,
It’s a fantastic job done and it really works. Nice job. God bless you
php file gets downloded rather than displayin the content
I have done all the setting and have been tryin from a couple of days to install php in IIS 5.1 , Am still facin the prob... any valuable inputs
Have a look at this article
This can be caused by a few things. Have a look at this article I wrote which covers the more typical causes. Let me know how you get on...
----------------
Dominic Ryan
5 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster
Awesome Tutorial
I just got Adobe CS5 and I've been having problems getting MYSQL to connect through it. Your tutorial FINALLY got me through it and now it works great. Thanks a million for all of your help!!!