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






Comments
PHP 5.2.10 or 5.3
Are sure you downloaded PHP 5.2.10? I've just had a look and php5isapi.dll is there. As of PHP 5.3 (which is currently in RC stage) phpisapi.dll will be dropped, so it is possible you've downloaded that one instead. If not, try downloading PHP 5.2.10 again.
----------------
Dominic Ryan
5 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster
Best PHP install guide!
This is easily the best installation guide I've found - better detail and background than others I've seen. I had an old PHP/apache installation, and using some other tutorials got into real trouble...
I used the uninstall PHP guide from this site, then used this guide to do a fresh install. I confess I was wary of using custom .vbs scripts on the uninstall but they worked perfectly.
Thanks for sharing your knowledge!
Richard
RY
Getting to environment variables is a little different in XP. You need to go to Start > Control Panel > System, instead of right-clicking My Computer.
XP environment variables
You can still get to your environment variables in XP using the method described in the guide. However you can also use the method you described, which also works for Windows 2003 Server. There is always more than one way to skin a cat with IT :)
----------------
Dominic Ryan
5 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster
Environment Variables
Do not put the PHP path directly at the end if you have MySQL paths also.
The following post is in response to PHP crashing when mysqli_fetch_assoc() is executed:
http://marc.info/?l=php-internals&m=123825270214607&w=2
Reprinted below:
Put the PHP directory first in your path, doing so will make the mysql extensions use the php's libmysql.
Dialog box to open/save file
Well darn. Its a great read and easy follow, but I am having issues. I have added mappings at the Server level and the Default Website level for
Extension: .php
executable: c:\php\php5isapi.dll
Win XP sp3 with IIS 5.1 and PHP 5.2.10.
I've unintalled and reinstalled a few times thinking I may have pooched something, but no love.
Prompt to download PHP file
Have a look at this guide I wrote on troubleshooting when getting a prompt to donwload a PHP file.
----------------
Dominic Ryan
5 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster
The specified module could not be found.
Hi Ryan, I am glad that you are still reply the question regarding this thread. I had done all as instructed. But while loading phpinfo.php, I got "The specified module could not be found." I am using WindowsXP SP2, IIS5.1, php-5.2.10, pecl-5.2.6 .
Popup gone - thank you!
So, if this isn't the weirdest thing I've ever seen...
So, per your advice, I look at your pop-up tutorial as well and go through each step making certain that everything is as it should be. I open the php.ini and find all the possible settings and everything is fine.
I then retry my phpinfo.php file (hello world) and BAM! Everything is working just fine. The ONLY thing I did was let the computer sit overnight and opened and closed the INI file - I MADE NO CHANGES!!
So, the only thing I can think this type of error relates to is your very last step - RESTART the machine - although I did do exactly that when I performed the install.
Anyway, thank you for your guide and your help. NOW, I can learn me some php!
MySQL
Not really a comment, but a problem. I've followed all your steps &when I run "phpinfo" MySQL doesn't appear. Can you point my in a direction that I can check to see what's missing? Thanks