Installing PHP 4.3 and Apache 2.x for Windows
Kerry Kobashi
January 30, 2003
Purpose:
This document describes the steps I took to get Apache 2.x, PHP 4.3, xmlDOM, and PEAR all running on a Windows NT 4 server. My goal was to simply get an in-house development system quickly up and running to play with. I'm sure there are a ton of other steps and tweaks that I missed but for now, my main goal was to learn, not create a production environment.
I have not tried to apply these same steps to a Windows 2000 Server or XP Server but I expect these instructions would be very similar in setting up those systems as well.
If you would like to add to these steps, please feel free to send me email. Any additional information would be helpful.
I hope this saves someone some valuable time!
- Kerry
Prerequisites
Make sure you have all the latest Windows NT service packs installed before proceeding.
=====================
Step 1: Installing Apache 2.x
- Download Windows MSI Installer
-------------------------------------------------------
Surf over to:
http://nagoya.apache.org/mirror/httpd/binaries/win32/README.html
Download the MSI installer from Microsoft
Run the windows installer to install it on your system
- Download Apache Distribution
-------------------------------------------------------
Download the apache distribution by going to one of the mirrored sites below:
http://www.apache.org/dyn/closer.cgi/httpd/binaries/win32/
At the time of this writing, version 2.0.44 was available.
Get the Apache MSI package by clicking on the apache_2.0.44-win32-x86-no_ssl.msi link
In Windows Explorer, double click on this package and follow the instructions to install
Edit configuration file
--------------------------------------
Next, you want to edit the httpd configuration file to get Apache to recognize the PHP file type.
Go to the start menu and look for the Apache icon group.
There will be a Configure Apache Server menu item with a link that lets you edit the httpd file.
Click on it and do the following:Change the server administration email address to something appropriate.
ServerAdmin somebody@somewhere.comSet the server name to be localhost on port 80 or your domain (i.e. www.yourdomain.com)
ServerName localhost:80Set the document root so that it points to the htdocs directory:
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs"Change the directory index file to the following. Note that I allow index.php to be used:
DirectoryIndex index.php index.html index.html.varChange the script alias to point to the directory where php will be stored. Here I use c:/php
ScriptAlias /php/ "c:/Php/"Add the php application MIME type:
AddType application/x-httpd-php .phpAdd the application executable type:
Action application/x-httpd-php "/Php/php.exe"Test Apache configuration
---------------------------------------------
Test out the Apache server by going to the start menu and looking for the Apache icon group again.
Run the Test Configuration menu item. If it runs, congrats!
Check out and bookmark the Apache documentation located here:
http://httpd.apache.org/docs-2.0/
==================
Step 2: Installing PHP 4.3
Install WinRAR
--------------------------
Get WinRAR 3.x, a nice little compression/decompression utility at:
http://www.rarlab.com/download.htm
Install WinRAR onto your systemCreate PHP directory
---------------------------------
Create a directory named C:\Php (notice case of letters)Get the PHP distribution
----------------------------------------
Surf to this URL to get the PHP distribution:
http://www.php.net/downloads.php
Download the complete Windows TAR source to C:\Php
Download the Windows binaries in zip format to C:\Php
Download the Windows PHP installer to C:\Php
- UnRAR and Unzip distribution
------------------------------------------
UnRar the TAR source
Simply open up Windows Explorer and navigate to the PHP folder
Right click on the file to unzip/unrar and click on the Extract Here menu item
Upon extracting of the TAR, you will get another RAR archive of larger size
Unrar that again by extracting here
Upon extracting of the TAR source, you will get a bunch of folders
All source will now be in the C:\Php\php-4.3.0 directory
Run the php-4.3-0-installer
There is an option to choose Apache, select it
You will likely get a message saying there was an error - ignore it
Unzip the Zip file by again asking WinRar to extract here (in C:\Php)
Edit the PHP.INI file
--------------------------------
Go to your Windows directory and look for the PHP.INI fileExample: add an extension - domXML
------------------------------------------------------
Lets take an example of how to add a extension. Let's add DomXML support.
Remove the semicolons in front of the following:
extension=php_domxml.dll
extension=php_iconv.dll
And point to the extension directory:
extension_dir = C:\Php\php-4.3.0-Win32\extensions
- PHP client support
-------------------------------
In the CLI directory is the PHP client
This client depends on php4ts.dll so you will want to copy the php4ts.dll file located
in the C:\Php directory into the CLI directory to make it run
To test that the client works, do the following:
With notepad create the following file, named test.php, in the CLI folder
<? phpinfo ?>
Save it as test.php
Launch a DOS command shell and type the following:
php test.php > test.txt
After execution, you will get the php information about your system located in test.txt
Open test.txt up with notepad
- Add PEAR
------------------
PEAR is a wonderful and useful framework for PHP development. I strongly recommend loading the packages and using them. The new installer is excellent and requires a simple DOS command.
Before proceeding, in PHP.INI, you will want to make the following change:
include_path = "C:\Php\pear
In the CLI directory, simply type in the following:
php -n -r "include 'http://go-pear.org';"
All pear packages will be downloaded to your C:\Php\pear directory