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

Truely 5 Steps and very easy

Thanks for a superb article. Read a few articles on installing PHP on IIS but couldn't get it done. This one did the trick.

Anonymous's picture

Thanks a lot, its easy and

Thanks a lot, its easy and nice article
Only one extra thing i did i repeated first part of the 3rd step for my virtual directory as well.

Anonymous's picture

Mail

So, I've got everything working with PHP using this guide, and the site I made works great!

However, I was wanting to extend the site to add an email verification thing (you know, where you have to click some link emailed to you to verify you're a person), and I was using the 'mail' function PHP has.

This is the first time I've ever touched email from PHP, so this may have NOTHING to do with IIS (It's Windows 2000 Server, so using IIS 5.0) and entirely to do with my naivety, but I can't get email to work. Here is my code:

$mail = mail('someone@something.com', 'Hello, world!', 'This is a message from PHP. Neat, huh?');

if ($mail == TRUE) {
printp('Mail sent!');
} else {
printp('Mail fail.');
printp($mail);
}

How would I get this to work? The email address there was edited, in my actual page it's using my own personal email address.

I have IIS's SMTP service installed, but I don't know how to configure that either. I've never touched email serving before, so this could really be just me being naive.

Anonymous's picture

You are a star

Mate, I don't know how many years ago have you posted this useful information. I was trying to learn PHP through a book, but their instructions to install PHP in IIS didn't work and I was stuck. This was just WONDERFUL information from you. Thank you very very very much.

Anonymous's picture

Is PHP5.3 much different when installing?

Excellent tutorial. I am getting an error in phpmyadmin -
Your PHP MySQL library version 5.0.51a differs from your MySQL server version 5.5.12. This may cause unpredictable behavior.

So I guess I need to upgrade PHP, or downgrade MySQL. Do you agree?
Is there any chance you will be posting instructions for installing PHP 5.3 on IIS? I tried following the same instructions but it doesn't work :(

Thanks!

Brashquido's picture

No ISAPI in PHP 5.3

You'd be correct with your guess. PHP 5.3 is a pretty big change from PHP 5.2, one of the most notable changes was the ISAPI interface (which is used in this guide) was dropped from the package. I will be creating an install guide, however it may be a month or two off yet.

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

Anonymous's picture

Excellent Doc - Thanks

It solved my problem on IIS5. Step by Step useful instructions.

Thanks a lot,
Bala

Anonymous's picture

Getting error: Execute Access Forbidden

I did everything as stated here, but i am getting following error. Kindly help.
HTTP 403.1 Forbidden: Execute Access Forbidden
Internet Information Services

Anonymous's picture

PHP installed by WAMP to be configured in IIS 5.1

Hi,
Before i start following the tutorial, i would like to clarify whether I can follow these steps if I have the php instance installed in my system through WAMP.
I have the WAMP server running and my php directory resides in C:\wamp\bin\php\php5.3.5

Please guide me..
Thanks in Advance

-
Vathsan

Anonymous's picture

PHP5Isapi.dll is not available in PHP 5.4

i tried to do installation with this article, but unfortunate that the downloaded php 5.4 do not contain the php5isapi.dll file.
also the PECL Win32 binaries is not found on php download site.

how can i complete this installation! can anyone suggest?