How to install PHP 4 on Windows

Warning: Abandoned
This page/script has been classified as abandoned and will no longer be updated. I will keep this page here indefinitely as a reference, but it will no longer be updated and I no longer offer support of any kind regarding content found on this page.

Note

This tutorial is for PHP 4.x and if you want the PHP 5 tutorial you are at the wrong place.

PHP 4

  1. Download & Unpack

    Download and install PHP from http://www.php.net/downloads.php, you should grab the newest 4.x.x Windows Binary zip package that will work on apache.

    My file was named: php-4.3.8-Win32.zip
  2. Unzip php. In my case, I unzipped to:
    e:\php\
    (make sure you do not end up with something like e:\php\php-4.3.8-Win32\)
  3. Rename e:\php\php.ini-dist it to php.ini
  4. Edit your php.ini

    Scroll down about halfway through the file and look for doc_root then change it to point to whatever your Apache DocumentRoot is set to. In my case: doc_root = "e:\public_html"

    Another thing you might want to change is you session path. Search for: session.save_path and change it to any existing directory. One reader pointed out the windows temporary directory works well (for windows directory, see "Some Notes" in next step). So session.save_path = "c:/windows/temp" or if you use 2k/XP probably session.save_path = "c:/WINXP/Temp"
  5. Copy php.ini to your "windows" directory.
    Some notes
    On Windows 95/98/ME "windows" directory is called %WINDOWS% on Windows NT, Windows 2000, or Windows XP it's called %SYSTEMROOT%.

    If you are unsure where that is, go to the Start menu > Run and type in %SYSTEMROOT% or %WINDOWS% and it will pop-up the directory you need
  6. Copy e:\php\php4ts.dll to your "/Apache2/bin/" directory overwriting any existing older file.
  7. Editing Apache Conf File

    Using Notepad open E:\Apache2\conf\httpd.conf (in the start-menu there should also be a "Edit the Apache HTTP Server httpd.conf Configuration File" shortcut). Either at the very beginning or end of the file add the following lines: (NOTE: be sure to change the e:/php/sapi/php4apache.dll to the directory you installed your php to)
     	LoadModule php4_module e:/php/sapi/php4apache2.dll
    	AddType application/x-httpd-php .php
    
    Important notes for Apache 1.3.x users
    For apache 1.3.x you will use the following lines in your Apache config file:
    	LoadModule php4_module e:/php/sapi/php4apache.dll
    	AddModule mod_php4.c
    	AddType application/x-httpd-php .php
    	
  8. Testing

    Restart Apache if it is already running. (if it doesn't start or you get errors, use your Apache "Test Configuration" shortcut to see why)

    To test your PHP simply create a test.php file and put these 3 lines into it. (When loaded in your browser, you should get a whole long list of php variables, settings, etc):
    <?php
    phpinfo();
    ?>
    
  9. Documentation Suggestion

    One weird thing I have noticed about PHP is that it does not come with documentation of any kind. If you are a php developer/programmer, I suggest you download the documentation. Downloads can be found on http://www.php.net/download-docs.php and I personally recommend the "English - Windows HTML Help" (chm) version as the search is so handy, although they all contain the same information.