PHP on Windows XP w/IIS – An Installation Guide

11 02 2009

Installing PHP on a windows XP operating system has been anything but simple. I have tried both the .msi installation and the manual installation. Working in windows the first thing I always go to is the msi (Microsoft Installer) file but I was completely unsuccessful with this endeavor. After utter failure I decided to attempt a manual installation, it was fairly easy to make it work, but hit a brick wall when it came to extensions. After I figured out how to make the extensions load, I repeated the process several times as to find the best method. I’m sure there are better methods out there but either no one is sharing or I couldn’t find one.

Step 1.
If you have not already installed IIS you will need to dig out your Windows XP CD, otherwise skip this step and move on to installing PHP. Navigate to Start > Run and type ‘appwiz.cpl’ and click ok or press enter, this will open up the Add/Remove Programs Control Panel Interface. From here select the Add/Remove Windows Components from the left menu. Select the Internet Information Server (IIS) checkbox and select Next, installing the software.

Step 2.
Download the PHP Manual Installation .zip package form php.net here is a link to the latest version 5.2.8
http://us3.php.net/get/php-5.2.8-Win32.zip/from/a/mirror
Save this file to the desktop, once downloaded extract all files to “C:\php”
Give the Internet user account Read/List access to the c:\php directory this account would be IUSR_COMPUTERNAME

Step 3.
Create / Configure the php.ini file
Open the file c:\php\php.ini-dist in notepad. Select File > Save As from the menu and save it to C:\php as php.ini
There are a few lines that need to be modified to set the proper configuration

Find this code block:

; UNIX: “/path1:/path2”
;include_path = “.:/php/includes”
;
; Windows: “\path1;\path2”
;include_path = “.;c:\php\includes”

remove the leading semi-colon ‘;’ from the bottom line to look like this:

; UNIX: “/path1:/path2”
;include_path = “.:/php/includes”
;
; Windows: “\path1;\path2”
include_path = “.;c:\php\includes

Find this line

 doc_root =

and change it to

doc_root =”c:\Inetpub\wwwroot”

Find this line

extension_dir = “./”

and change it to

extension_dir = “c:\php\ext”

Now select the extensions that are to be used they are locate below the line with this text

; Windows Extensions

Simply un-comment each desired extension by delete the preceding semi-colon “;” here is a sample of the gd2 extension set to enabled

;extension=php_dbase.dll
;extension=php_exif.dll
;extension=php_fdf.dll
extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_gmp.dll

there are several extensions available only use the ones needed.

Click File > Save
Copy this file to c:\Windows as well

Step 4.
Add c:\php to the windows path
Right-Click My Computer and select properties
Click the Advanced Tab then the Environment Variables button near the bottom.
In the system variables group find the variable called path and modify it’s value to include c:\php

It should now look similar to this
C:\php;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem

Step 5.
Configure IIS to use PHP
Visit Control Panel > Administrative Tools > Internet Information Services
Drill down until you find a node called  “Default Web Site” Right-Click this and select Properties
Select the ISAPI Filters Tab and then the Add button.

Fill in this information

Filter Name: PHP
Executable: C:\php\php5isapi.dll

Click OK
Next select the Home Directory Tab then the Configuration button near the bottom
Press the Add button

Enter the following Information

Executable: C:\php\php5isapi.dll
Extension: .php
Verbs: All Verbs
Script Engine: Checked
Check that file exists: Uncheck

Presss OK

Step 6.
Create a PHP configuration test page.
Open Notepad and paste the following

<?php
phpinfo();
?>

Save this file as c:\Inetpub\wwwroot\phpinfo.php

Step 7.
In the command prompt run the following commands

net stop iisadmin

net start w3svc

Step 8.
Start your web browser and visit http://localhost/phpinfo.php
You should now see that php is working but the extensions may not be loaded, usually a reboot will allow this to happen.

In the event that there is a problem and you are not seeing the phpinfo page make sure that the IIS configuration is correct. If there are problems getting extensions to load the best place to look is the phpinfo page, it will show information that can help you to track down the problem.

Advertisements

Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: