Installing PHP 5 on IIS in 5 simple steps

Categories:

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.

Comments

Anonymous's picture

THE BEST GUIDE FOR PHP

THANK YOU

Anonymous's picture

BEST GUIDE

THANK YOU!!! your last comment fixed my problem!! Very good thinking and analysing of problems through posts, which my lecturer couldnt solve in 10 emails. Keep it up!!

Anonymous's picture

Great Guide

This tutorial was a life saver. I attempted to install php 4 times before coming across this guide which was the first that I could follow from beginning to end. Much appreciated.

Anonymous's picture

Only one thing missing

I had to enable read access to php5isapi.dll on IUSR_. Won't everyone have to do that?

Brashquido's picture

You shouldn't have to give

You shouldn't have to give read access to the IUSR account unless the default permissions have been altered. Have you removed any of the default permissions from your PHP directory?
----------------
Dominic Ryan
3 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster

Anonymous's picture

Excellent Guide for Beginners Like me.

This page is an excellent guide for new programmers. After installing php5 on IIS5 I spent many days breaking my head to make it work. Many other guides didnt help. Thanks to Dominic Ryan. KEEP IT GOING
John

Anonymous's picture

Good Job But can you explain how to do it with Fastcgi Go live?

I think also this is a excellent guide.
But with so many expectations about using Fastcgi GoLive I would like your help about installing PHP 5.2 using FastCgi on Windows 2003
Thanks
AT

Anonymous's picture

The php code isn't executing

Dude, tks a lot for your tut. I've done everything right. I tested the installation with the "test.php" page and it is displayed correctly. The only (but a terrible headache) problem is that every single page with .php extension isn't showing.

I mean, when i try to visualize some php page, my browser only displays a blank page, and nothing it''s working. I have checked my server, and everything is fine. Can anyone helpe me?

Brashquido's picture

I'll look at putting

I'll look at putting together a FastCGI guide this week, or next week at the latest.

If you are getting blank pages, then you might like to make sure that your error reporting in php.ini is turned on. In particular make sure you have these settings;

error_reporting = E_ALL

display_errors = On

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

Anonymous's picture

HTTP 500

Hi, nice guide there, though i have some problems
On execution of any PHP file, i get the HTTP 500 error, and IE7 wont give me more details. Im using WinXP Pro, IIS5.1 and PHP 5.2. Also i got MySQL 5.0 installed. my main reason for installing PHP on my IIS server is for vBulletin, though i cant seem to run any PHP application. Mappings are correct, Environment Variables are correct too, though i installed PHP in "C:\Program Files\PHP" and i got an error to put quotes around the address when making the mapping, and instead of the normal format: C:\windows\inetserv\asp.dll, my PHP executable is in qutoes because of the between 'Program Files': "C:\Program Files\PHP\PHP5isapi.dll"
Any help will be greatly appreciated, ill be waiting for a response