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.


Anonymous's picture

php.ini - missing line causes file download prompt and so on...

As far as I can see, the only thing that's missing is another change to the php.ini file regarding cgi.force_redirect setting.

The value MUST be set to zero. The php.ini file reads:

"cgi.force_redirect is necessary to provide security running PHP as a CGI under most web servers. Left undefined, PHP turns this on by default. You can turn it off here AT YOUR OWN RISK
**You CAN safely turn this off for IIS, in fact, you MUST.**"

Before I changed that setting, I had the same problem as a lot of people writing comments here: prompt for file download instead of displaying the page when using a web browser to connect to http://localhost.

I went through a couple of guides and none of them worked for my system. I am using Win XP with IIS 5.1 and I've tried to follow the manual installation steps described on the PHP site but it didn't work for me.

I just couldn't get FastCGI to work with PHP 5.3.3 no matter how hard I tried. I did everything by the book several times, nothing... When I chose php-cgi.exe for the executable - it worked but I wasn't sure if that's the way to go, so I decided to try it with your instructions.

Seems to be working fine, except for that initial

Anonymous's picture

how to put the file in website

i created phpinfo.php file using notepad.But how to place it in website and test using web browser.


Brashquido's picture


Hi John,

Usually you'd use something like FTP to upload your files to your webserver. Ultimatley it depends on how you connect to your server though. I'd recommend contacting your host to determine which method to use.

Dominic Ryan
6 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster

Anonymous's picture

IIS 5.1 being prompted to download .php

I spent a couple of days trying to get PHP 5.3 and FastCGI working with IIS 5.1. Symptom: it would hang, it would be blank, it would prompt for download depending on how I tinkered. The catch? I was doing the Mapping (.php to fcgiext.dll) correctly in IIS except applying it to the Web Sites folder instead of Default Web Site which is one below that in the IIS listing. I gather Default Web Site is the one that corresponds to where I have phpinfo.php test file with and I had been assuming subdirectories inherit the mappings automatically. Not so. I also had a problem with the OK button being grayed out when browsing for the mapping dll - and found you just need to click your mouse in the text box where the path is.

Anonymous's picture

Prompted to download the phpinfo.php file

I was having this problem with PHP Version 5.2.17, all I had to do was change the configuration and setting the php5isapi.dll on page 3 for each of my IIS website virtual directories that I have already made before installing PHP. (remember to restart IIS afterwards)

Thanks a great tutorial on PHP...

Anonymous's picture

Many thanks, Fantastic post.

Many thanks, Fantastic post. The best I have seen regarding installing and configuring PHP and MySQL for IIS.
I have installed everything as your instructions and it is working perfectly.

Although I do have an issue with OWA and activesync that you may be able to help with.

I am using SBS2003 on the IIS default web site.

Before installing Wordpress, PHP and MySQL, OWA and activesync were working fine. After installing Wordpress, PHP and MySQL, both OWA and activesync will not accept the login credentials. Index.php and PHP are affecting the default home documents of the default web site, everything is run through index.php.

To problem solve the issue, I have created two Home Directory folders for the default web site, one with the default setup (including default.htm, default.asp, index.htm, default.aspx) and the other with default setup AND the wordpress .php files. When I set the local path of the home directory to the folder that contains the .php files, our PHP web site functions perfectly BUT the OWA and activesync will not accept the login credentials. If I change the home directory to the folder that does NOT contains the .php files, OWA and activesync both function perfectly, but obviously our PHP web site does not function tech talks.

Any suggestions?????

Anonymous's picture

Top man

Great guide, thx a lot.

Anonymous's picture


This was a good guide to have PHP up and running on IIS, but I have done this all, but unable to get the PHP page to work. It shows the error as
"The page cannot be displayed
There is a problem with a program on the page you are trying to reach, and the page cannot be displayed."

I had this PHP running previously, until I re-installed the OS(XP), can't get this to work. I installed PHP, configured env variables, set the mapping to 'php5isapi.dll', set all the paths in php.ini, but no luck as well as no sensible errors. Can't decide, where to start searching. It is as if the PHP.ini is not being recognized, even though it is present only in 'wwwroot'. Tried mapping to 'php-cgi.exe', and force redirect to 0; still no go.

Need help or what am I doing wrong ?

Anonymous's picture


This is to add to my last post, where I was not able to get PHP running and got the error as 'The page cannot be displayed'.

This turns out to be execute permissions to be set in IIS. Somehow this keeps reverting back to 'none' when a php page is accessed, leading to the error. I guess if you have done everything right, checking the IIS configuration would definitely save a lot of hair and time rather than tampering with the PHP installation.

Also, the php.ini path seems to be bouncing around between C:/Windows and the installation path of the PHP. Not sure what is causing this though...

Brashquido's picture

IIS applications and/or multiple PHP installs?

Sounds like a bit of a headache. This sort of behaviour can be caused by a few things, my guess would be something like there being multiple PHP mappings in IIS as well as possibly multiple instances of PHP. Honestly you can spend hours trying to fault find these sorts of errors, and being a Windows 2000 server I'm guessing this is not a new install. My advice would be to start from scratch by doing a full uninstall of PHP on IIS, and in doing so you are ensuring your IIS environment is as clean as you can realistcally get it before installing PHP.

Dominic Ryan
6 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster