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






Comments
help
i have tried the steps..thrice on different systems.but my php code doesnt run.I get a blank screen when i test.
When i read other help sites. somewhere it was mentioned that in my php.ini i need to change doc_root to "C:\Inetpub\www"
should i do that?will this solve the problem?
is it required..ppls help me
PATH variable is read from left to right
My answer is both yes and no. If you look at the first page of my guide I mention that it is very important that all previous versions of PHP are completely removed (which can be done by following my guide on how to uninstall PHP from IIS). The only time that adding your PHP install path to the beginning of the PATH variable string will be of benefit is if your PHP dll's & exe's are accessable via other paths accessable via the PATH variable (hope that makes sense). This is because your PATH variable string is read from left to right, and is also why I consider it bad practice to copy ANY PHP files into your Windows directories. With my IIS Aid PHP Installer I use the same technique because there is no other way the installer can reliably get PHP working on a server where there is no knowledge of existing PHP files on the system.
So to cut a long story short. Adding your PHP path to the start of the PATH variable string won't hurt, however if installing on a clean system it should not make a difference.
----------------
Dominic Ryan
5 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster
doc_root not required
The doc_root directive is not required for PHP to operate. If you are getting blank pages then you'll need to enable PHP logging or set display errors to on in php.ini. Remember to restart IIS after you've made the changes for them to take effect.
----------------
Dominic Ryan
5 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster
thanx
this is very helpful thanx bro
CHOICE
Tried a few other install giudes with no luck. Yours was simple yet detailed. Worked first time.
Thanks
PHPMyAdmin Settings
Hi Dominic,
I wish to change the settings within PHPMyAdmin and was wondering how I could do so.
1. When adding privileges for databases, I wish to the host text field to not appear as I wish to hardcode the host/IP name/address.
2. When downloading SQL scripts, I wish the name of the file to read the name of the database rather than the name of the server
How can I change these?
Michellea
Installation Directions EXCELLENT!
GREAT JOB! Took all of 10 minutes!
Great tutorial!
Absolutely perfect! I tried some other instructions but they failed me, I am an advanced computer user and these instructions were absolutely right on target, thank you!
Brilliant Guide....
This guide is SPOT ON...100%....took no more than 10 mins :)
Thanks a million.
The lastest PHP install doesn't have php5isapi.dll....
I installed PhP 5.10, (after following the link in the instructions), and then I found the 5.2.6 version of PECL and extracted in the ext directory. Now, following the instructions to add the .php extension, I find that there is no php5isapi.dll or anything with a similar name, in any of the directories. Does anyone know what I've done wrong?
- Thanks