Installing PHP 5 on IIS in 5 simple steps

Categories:

Yes, yet another PHP 5 installation guide. Why write one when there are already dozens of them out there? Well there are two main reasons: firstly I will be writing a lot of guides that require PHP to be installed and working and I will need something to point people to who have yet to install PHP. Secondly, I have read a lot of the guides out there and found that a good portion of them over complicate the process. It really should not be that hard or perplexing. In this guide we'll break down the process of installing PHP 5 on IIS into 5 simple steps that are easy to follow that works for IIS 5, IIS 5.1 and IIS 6.

NOTE: This guide is intended for use with PHP 5.2.x and below. A guide for PHP 5.3 and above will be published in the coming weeks.

So what are these 5 simple steps? In a nutshell, this is all you need to do to install PHP 5 on IIS;

  1. Download and Extract PHP 5 (we'll install PHP 5.2.1 on IIS 5.1 in this guide)
  2. Set your environment variables
  3. Set the PHP application mapping in IIS
  4. Configure php.ini
  5. Restart & Verify

Just before we continue I thought it pertinent to mention that it if you have already installed, or attempted to install PHP on your system then you must remove all traces of that install before continuing. If ANY PHP files exist anywhere else on your system that are accessible via the PATH environment variable, then it is very possible (even probable if the previous version of PHP was different) that you will have issues with hosting PHP content.

If you are wanting to install PHP 4, then the process is slightly more complex than installing PHP 5 and involves steps not covered in this guide. Not to worry as it is even easier for you. All you have to do is download the IIS Aid PHP Installer from this site and run the fully automated GUI installer. This installer will completely setup your PHP 4 environment, including all environment variables, IIS scriptmaps and IIS 6 web extension. The particular advantage of this installer is that it configures PHP 4 to use FastCGI mode as well as an Opcode cache for maximum performance. Expect to see some articles of just how much faster here in the future.

1. Download and Extract PHP 5

Nothing taxing about this, simply go to the PHP download page and download the latest PHP zip package from under the "Windows Binaries" section, along with the latest PECL Win32 binaries (do not get the ones marked "non-thread-safe" unless you plan to use CGI/FastCGI as otherwise you run the risk of a race condition). Save the PHP zip package to the directory where you will want to install PHP (e.g. D:\PHP), and then extract. Once extracted you'll see inside your PHP installation directory a sub directory called "ext". Save the PECL Win32 binaries download into it (e.g D:\PHP\ext), and then extract. Your PHP install directory should now contain all the content of your PHP zip package file, and your ext sub directory should contain the contents of your PECL Win32 binaries file. From here move back to the root of you PHP installation directory (e.g. D:\PHP) and create three directories, one called sessions, one called upload and one called log. In the log directory create a new file called php.log. First step licked.

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