So here it is, a quick step by step on getting PHP5 installed on a Windows Server running IIS 6. These are steps to follow for a clean install. If you have failed installations and came across this post seeking help, remove the installation completely. By that I mean, remove .php file mappings, ISAPI extensions, registry settings you might have tried, EVERYTHING. Even delete the PHP install folders. Remove anything you may have gone and dumped in your \Windows or \System32 folders. Get your machine/server back to just plain old IIS running the usual .Net, ASP etc. stuff. Preferably reboot the machine for everything to take proper effect.
THEN
1. Download the latest build of PHP from their site: http://www.php.net/downloads.php
For the purposes of this post I am referring to PHP version 5.
2. DON’T download the installer, it’s crap. Download the zip file instead for manual extraction and installation. (Not as painful as it sounds)
3. Once downloaded, extract the contents to a folder like C:\PHP or something. A folder somewhere without spaces in the path is preferred. I’ll continue with the assumption that this will be your working folder.
4. Open the folder you have just extracted the files to, and find the file named php.ini-recommended. Rename this to php.ini and open it.
5. Find the spot with the following line:
extension_dir = "./"
and change it to
extension_dir = "C:\PHP\ext"
This just points PHP to the correct extensions directory.
6. Now we have to set up the environmental variables to help PHP find its way around the server.
Right click "My Computer" –> Properties –> Advanced
Click "Environment Variables" at the bottom
![]()
Under "System Variables" find the "Path" variable in the list
Select it and click "Edit"
Edit the value by adding ";C:\PHP" to the END. (including semicolon). Hit OK
Now click the "New" button to add a new System Variable.
Variable Name: "PHPRC"
Variable Value: "C:\PHP"
![]()
7. Now open your IIS Management Console.
Right-click the "Web Sites" node (not any particular web site in the list), Click Properties.
Click the "Home Directory" tab, then click "Configuration"
On the "Mappings" tab, click "Add" to create a new mapping.![]()
Click Browse to locate and select the file "C:\PHP\php5isapi.dll"
In the "Extension" field enter "php"
Hit OK to save and close. OK all the way out.
Now Right-click on "Web Service Extension" and click "Add a new web service extension"![]()
Extension name: "PHP ISAPI"
Required Files: Click "Add",
Browse to and select "C:\PHP\php5isapi.dll" and hit OK
Check the box that says "Set extension status to Allowed"
Hit OK
Now IIS and the server is completely configured to run PHP5.
REBOOOOOOOOOT!!!!!
This is needed to let everything take effect, especially the environment variables and ISAPI extensions.
8. Next, create a text file called info.php with the following code in it:
Place the file in your web root and browse to it.
You should get a nice dump of your entire PHP setup in beautiful purple and gray
Only problem here would be the fact that you don’t see any of your extensions mentioned in the file. Most of you will be wondering why PHP can’t make any kind of Database connections using mysql_connect() in particular.
Well this is solved by going back to your php.ini file.
Find the section:
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;
A few lines below that you’ll see a list of commented out lines looking like:
;extension=php_abcdef.dll
Simply uncomment (remove preceding ";") to enable the necessary extension. Most of them will be in the C:\PHP\ext directory, double check before enabling it to make sure the files exists else you’ll get errors.
Restart IIS after making php.ini changes;
Start->Run->iisreset
AND THAT’S IT!
Everything should work perfectly fine after that.
Let me know how it all goes.