Installing PHP 5 on IIS in 5 simple steps


Configure PHP.ini

You could very easily write a series of articles regarding setting the various php.ini directives, so to try and keep this article short I will just deal with the basics here. When serving PHP on IIS the php.ini file is the only place that options are set, and if no php.ini file can be found then the defaults are loaded. The limitation of a single php configuration for an entire server is perhaps one of the biggest disadvantages with hosting PHP applications on IIS, especially in shared hosting environments.

There are actually only a handful of setting you will might want to look at configuring in php.ini, and they are the path to your extensions, sessions, and upload directories. You'll also may wish to enabled a few PHP extensions to get added functionality from PHP that might be required by some PHP apps, and perhaps set some PHP logging options.

  • Open your PHP installation directory (e.g D:\PHP) and copy php.ini-recommended and rename the copy to php.ini
  • Open php.ini and do a search for extension_dir = "./" and replace it with extension_dir = "D:\PHP\ext" where D:\PHP\ext is the path to your extensions directory (it's the one with all the files that begin with "php_" in it). The path to your PHP installation will be used for the next several steps, so take care that you modify them to suit your own environment.
  • Search for ;session.save_path = "/tmp" and replace it with session.save_path = "D:\PHP\sessions" (note the semi colon (;) is removed). This will be used to store PHP session information which is used by many PHP applications.
  • Search for ;upload_tmp_dir = and replace it with upload_tmp_dir = "D:\PHP\upload" (note the semi colon (;) is removed). This is used for all your HTTP upload files, and if not set your system temp will be used.
  • Search for ;error_log = filename and replace with error_log = "D:\PHP\log\php.log" (note the semi colon (;) is removed). This is where all your PHP logging information is kept when enabled. You can also configure PHP to log data to your Event Log, but it requires loosening the privileges on the IUSR_COMPUTERNAME account IIS uses.
  • Search for ;extension=php_mysql.dll and remove the semi colan (;) from infront of it so it appears as extension=php_mysql.dll. You'll almost certainly need this PHP extension loaded as any PHP application that uses the MySQL database will need it.


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