Installing PHP 3.x.x for Apache 1.x.x on Windows 9x

by Nathan Wallace (Sep 30, 1999)

Introduction

These instructions assume that you installed Apache for Windows 9x as outlined here. They should work with any standard Apache installation.

Getting PHP

  1. Make a directory, c:\php.

  2. Download the PHP distribution from your nearest mirror. Here's a direct link to php-3.0.11-win32.zip.

  3. Save the PHP zip file into the directory c:\php

Installing PHP

  1. Open Windows Explorer from your Start Menu.

  2. Go to the c:\php folder.

  3. Double click on the php zip file, php-3.0.11-win32.zip or equivalent. Hopefully you have winzip installed and this will work. Otherwise, you need to get winzip from somewhere.

  4. Extract the files out into the c:\php directory.

Configuring PHP

  1. Copy the distribution PHP3 ini file into the c:\windows directory as php3.ini. Here are the commands in a DOS box. If you installed windows into some non-standard directory like c:\win98, then you must use that directory instead. Make sure that you rename the ini file!!!
        cd c:\php
        copy php3.ini-dist c:\windows\php3.ini
    

  2. Now we have to edit the PHP ini file. First we must tell PHP where it can find the dll's for the extensions. On line 100:
        ExtensionDir = "c:\php"
    

  3. If you plan to use MySQL (or some other modules) then you must enable those extensions. You can do this by uncommenting the relevant lines. For MySQL it should be on line 115:
        extension=php3_mysql.dll
    
    You may also need to set some of the MySQL parameters in the ini file.

Configuring Apache to use PHP

  1. We need to make a number of changes in the httpd.conf file. This file is located at:
        c:\Program Files\Apache Group\Apache\conf\httpd.conf
    
    First we must add a script alias for PHP around line 459:
        ScriptAlias /php/ "c:/php/" 
    
    We need to make Apache aware of the PHP file types. These can be any extensions that you wish to use, I've chosen php3, phtml and phps for PHP source. Add these around line 594:
        AddType application/x-httpd-php3 .phtml
        AddType application/x-httpd-php3 .php3
        AddType application/x-httpd-php3-source .phps
    
    Now we need to tell Apache to use the PHP parser to handle php types. Add an Action directive near line 641:
        Action application/x-httpd-php3 "/php/php.exe"
    
  2. You will need to restart the Apache server for these changes to take effect.

Checking it works

  1. Restart your Apache server if you haven't already done so.

  2. You can check that Apache is still working by just opening a browser and going to the URL http://localhost. If you see a page that says "It Worked!" (or whatever page you normally see if you've already been using Apache), then obviously Apache is still working.

  3. Let's create a test PHP file in:
        c:\Program Files\Apache Group\Apache\htdocs\test.php3
    

  4. This file should contain a single line like this:
        <?php phpinfo() ?>
    

  5. Point your browser at http://localhost/test.php3. If you get an error then you have done something wrong. Otherwise you should see a page that looks something like this (link removed).