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

Excellent Guide

This is fourth set of instructions that I am looking at to get PHP to work. For some reason mmc.exe would stall each time I would attempt to use Window's IIS GUI to associate .php with the dll. Hence the IIS would not parse the php pages.

Running that VB script did the trick (I just had to modify the Root directory letter once the script was finished).

Thank you for such an excellent guide.

Brashquido's picture

No problem, glad it was

No problem, glad it was useful for you.

Anonymous's picture

PHP5 and MySQL5

Thanks for your good job. Your guide was a precious help. Thanks to it I could finally install PHP5 with MySQL5 on IIS. Really nice work!

Anonymous's picture

Is it just me?

Or are the graphics in this post broken?

Brashquido's picture

It's not just you, the

It's not just you, the images are not being displayed for some reason. Have a feeling that my server side HTTP cache might have an issue or two. I'll fix it tonight when I get home, so check back again in around 12 hours or so. Thanks for letting me know :)


Should be working again now :)

Anonymous's picture

prompt for downloading .php file

Great tut!

but if i do all the steps and test it at the end, internet explorer prompt to download the .php file... :-S

It is in the root of the webserver, tried other locations too, but with the same result...

any explenation??


Brashquido's picture

Do you have a mime type

Do you have a mime type setup for PHP?

Anonymous's picture

To make things a little more clear

You can't do an include or a virtual include to test the php page for some reason that didn't work. Alll I did was made an <a href> tag that references the phpinfo.php page in the default.htm of the server directory and clicked on it to test the php implement.

Anonymous's picture

Spelling and Grammar

Check your spelling and grammar. Readers may loose confindence in the technical portion of the article if the non-technical language has spelling and grammars errors.

Anonymous's picture

Promt for downloading .php file

I get the same problem, I have made a href i another html file where I link to the php file, and yet it wants to download the file. I use IIS 5.1, followed all the steps.