Install & Configure PHP 5.x on Windows Server 2003 with IIS 6

This guide will show you the necessary steps to install and configure PHP 5.2.1 (5.x) on Windows server 2003 using IIS 6 as the web application server. This guide does not show you how to install Windows server or install IIS, just the config steps neccesary after install.

Here are the steps;

  1. Install PHP
  2. Configure PHP
  3. Configure IIS
  4. Test the install

Here we go…

Step 1: Install PHP

  1. Get the latest version of PHP from php.net. Get the latest binaries but not the Windows installer as we are going to do all the dirty work by hand… Don’t worry, there’s not too much…
  2. Get the latest version of the PECL Modules too if you need these specific extensions for you application. If you’re not sure, get them anyway and wait until later in the install before loading them onto your server…
  3. Create a directory on the root of your server system drive in which to extract the PHP files. I use C:\PHP (tada!).
  4. Unzip the binaries into the C:\PHP folder. You will now have a directory structure that looks like this:
    • C:\PHP
    • C:\PHP\DEV
    • C:\PHP\EXT
    • C:\PHP\EXTRAS
    • C:\PHP\EXTRAS\MIBS
    • C:\PHP\EXTRAS\OPENSSL
    • C:\PHP\EXTRAS\PDF-RELATED
    • C:\PHP\EXTRAS\PEAR

    This is the basic directory structure as of version 5.2.1.

  5. If you know you need the PECL extensions you can extract those now. If you’re not sure you can come back to this point later and extract them. Either way, extract the files into;
    • C:\PHP\EXT

Step 2: Configure PHP

  1. In your C:\PHP directory you’ll find a file named php.ini-recommended. Rename or copy and rename that file as php.ini.
  2. Open php.ini up in your favorite text editor and preform the following edits (I’ve listed them in order as of PHP version 5.2.1)
    • extension_dir = “c:\php\ext\”
    • cgi.force_redirect = 0
    • browscap = “c:\php\extras\php_browscap.ini”
    • session.save_path = “c:\php\sessions\”
  3. Install a browscap.ini file. This is optional but prefered so right mouse click and choose Save Target As… here to get the php_browscap.ini that I’m using or else search and find the one you want. Then copy it to c:\php\extras\php_browscap.ini (rename it from .txt to .ini).
  4. Create a directory for the PHP session files. I chose to use C:\PHP\SESSIONS\ initilally. Create it here to start and when the install works then move it onto a different drive if you want.
  5. Add C:\PHP to your servers path environment variable.
    • Right click My Computer, Properties and select the Advanced tab, then click on the Environment Variables button.
    • Select the Path variable and click the edit button.
    • Add C:\PHP; to THE BEGINING OF THE ENVIRONMENT STRING
    • Click on OK.
  6. Add New variable PHPRC to the Environment Variables.
    • Click the New button
    • Variable name is PHPRC
    • Variable value is c:\php
    • Click OK.
  7. Clcik OK back to desktop.

Step 3: Configure IIS

Add PHP ISAPI Extension

  1. Open IIS Manger
  2. In the left pane select Web Service Extensions
  3. Click the link Add A New Web Service Extension…
  4. Extension name is PHP 5.2.1 Extensions (Name can be whatever you want)
  5. Click the Add… button
  6. The path to the file is C:\PHP\php5isapi.dll
  7. Check the Set Extension Status Allowed… checkbox
  8. Click OK to finish

Add .PHP Extension

  1. Right click on Web Sites and choose Properties
  2. Select the Home Directories tab
  3. Click on the Configuration button
  4. On the Mappings tab click the Add… button
  5. Executable browse to C:\PHP\php5isapi.dll
  6. Extension is .php
  7. Select Limit to: and type GET,POST,HEAD
  8. Check Verify that file exists and click OK. Then OK again to get back to the Home Directory tab of the Web Sites properties dialog
  9. Set Execute Permissions to Scripts only
  10. Click OK.

REBOOT THE SERVER!

 

Step 4: Test the Install

  1. Download this test file and copy it to a working website folder on your web server. i.e. yourdomain.com/info.php (rename it from .txt to .php)
  2. Open the url in a browser http://yourdomain.com/info.php
  3. If the install is good you will see something that starts off like this;

PHP Info Display

Please look at the 6th entry, the path to the php.ini file. If it’s your path, you have a good install and you can continue with the rest of your setup for the particular PHP system you are putting in. If it’s not your path, go back to the Environment Variable setting and make sure you put the variable at the FRONT of the path string.

That’s about it, good luck!
Stephen Tickner

, , , , , , , , ,

2 Responses to Install & Configure PHP 5.x on Windows Server 2003 with IIS 6

  1. Amir April 19, 2007 at 10:30 am #

    Hi, i installed all the stuff on this page. but the functions: fopen, fclose, fput, flock and fread dont work! and i have no idea how to make it work. please let me know if you have any ideas….

  2. rogotenin July 6, 2007 at 1:40 am #

    Hello

    I am Lucy, I have found your website while searching for some info at Google. Your site has helped me in a big way.

    G’night

Leave a Reply