Installing PHP 5 on IIS in 5 simple steps


Restart and verify

Almost done now. Restart your server so that all the changes we have made are made effective in one swoop. Once your server has restarted create a file called phpinfo.php and place it in one of your websites that you can get access to. Open the file and enter this code;




Save the file and then open your web browser and access you phpinfo.php file and you should be presented with a screen detailing your PHP configuration. If this is what happens then you are up and running, if not then something has gone amiss. Feel free to ask me for help in the forums though.

As already stated if you require PHP 4 (for legacy code, etc) then your job is much easier. Just Download the IIS Aid PHP Installer and run through the GUI based installation wizard and everything is setup for you. With PHP now enabled you are on your way to being able to utilize one of the most popular web scripting languages in the world, which is used by thousands of free, and commercial web applications. Be sure to check back on this site in future for some PHP tuning tips and performance comparisons to make sure you are getting the most out of your PHP environment.


Brashquido's picture

For those of you that are

For those of you that are being prompted to download their php files rather than them being processes server side, double check you application mapping settings as per figure 9 above in the article. The ONLY way I have been able to successfully get IIS 5.1 to prompt to download a php file rather than process it is if the application mapping is incorrect. IIS will not let you save the mapping if the path to the php5isapi.dll is incorrect, so be sure that you have .php as the extension. If you have IIS Lockdown/URLScan installed, then you will need to add .php to the allowed extensions list.

Sorry about any spelling/grammar errors. I do my best, but unfortunately I am a product of the spell checker age and as the text editor on this site is very basic and doesn't have a spell checker there is bound to be the odd mistake that gets through. Feel free to point any mistakes out.

Anonymous's picture

This might be your problem

Brashquido, I believe I have my IIS and PHP5 set up correctly and this how I test it:


so for example I test my phpinfo.php page as follows:

http://localhost/ServerDir/phpinfo.php where ServerDir is my virtual server directory.

I think a lot of people are testing their pages like this:


so it would be like I was doing this:


This prompts me to download the .php file, if others are doing this just make sure you're testing it with the localhost url.


Brashquido's picture

That's a very good point

That's a very good point Brandon. For PHP scripts to be properly processed you need to access you PHP scripts via IIS, not windows explorer.

Anonymous's picture

Restart your server

Thanks for this excellent article Brashquido! I do have a newbie question though. When you say "Restart your server..", is it enough to stop and start the web services in IIS, or does the whole machine need to be rebooted?

Brashquido's picture

The main reason to restart

The main reason to restart your server is to update the environment varaibles. A restart might not be necessary, but it is one way to be sure the environment is refreshed properly upon install. Restarting your IIS services could well be enough. When you do it be sure that the Path variable from under the Environment section of the output of your phpinfo.php file contains the correct environment variables.

Anonymous's picture

Disabled Buttons

Hello Brashquido,
For some reason i could not add new mappings through the gui using iis5.0 because the OK button was disabled at the add menu in the configuration. But thanks to your great tutorial which points to a very nice script i could add the mapping. I have two more questions that i will be glad if you could answer. 1-Do you have an idea about why i am facing this strange problem about disabled buttons in the add mapping menu(i am new to web programming maybe its not strange but couldnt find info on the net)
2-My need was to add .html and php-cgi.exe mapping so that i could view embedded php. Now its working fine at last,but only for the root directory. So if i create a new virtual directory although it works for the root directory and i still see .html in the mappings for the new virtual directory, i cannot have the php code executed at the virtual directory- like in the initial situation.Why do you think this happens?
Thank you very much,

Anonymous's picture

Re: prompt for downloading .php file

I got the same problem as well. Upon inspection, i noticed that the Application mappings for the "Websites" (the one that was added to in this article) and the Application mappings in "Default Web Site" (under Websites) were inconsistent.

I fixed this problem, by following the same instructions in this article on doing the application mapping, except, i right clicked "Default Web Site" and selected Properties->Home Directoiry tab -> Configuration button and did the mapping from there.

Brashquido's picture

That's correct. If you add

That's correct. If you add your PHP application mapping at the root, then only websites created after you add the mapping will inherit the mapping. If you have existing websites you wish to use PHP on then you'll need to add a PHP application mapping at the site level.


At a guess I would say that buttons are grayed out due to a permissions issue. Not sure though as it has been a few years now since I'e worked with IIS 5.0 in depth. Make sure you are using a user account with full administrator privileges. Second issue sounds like your execute permissions are not set to enable cgi. This setting is in your virtual directory properties under the virtual directory tab. Make sure it is set to scripts and executables. If you have any further issues I'd appreciate it if you could post them in the forums so it does not fragment the comments discussion on this article. I'll be more than happy to help you out.

Anonymous's picture

where is the popup menu?

Hi Brashquido,
I'm so new to PHP. Hope you can help me. I'm testing a php website in my computer 1st using IIS (running windows XP Pro). I already installed PHP 5.2.3 & pec, learned from ur tutorial, & also the configuration. The website i'm testing is begin with index.php contains popup menu from other directory i.e. /gbl/inc/
But i cannot let go into index.php when typing "locahost" at Internet Explorer.
Or any settings i need set for that?

- William

Brashquido's picture

Hi William, I'm not 100%

Hi William,

I'm not 100% sure on exactly what you're asking, but from what I can gather is that you PHP app is not initialising a menu as it should. In the setup of some PHP apps you need to specify the URL the app will be served from, and if your app is accessed from any other URL then it might cause problems. Double check that you are accessing your app via the URL you specified during setup. You may need to add an entry to your hosts file so that the URL you specified resolves to your localhost, e.g resolves to