Running Apache 2.2.x PHP 4.4.x and MySQL 5.1.x under Windows Server 2003

These are steps I took to successfully launch old PHP 4 website on windows 2003 using following software:

Apache 2.2.17

MySQL 5.1.53

PHP 4.4.9


1. Download and install PHP 4.4.9

You can download PHP 4.4.9 from here

After download is finished just extract it to C:\php


2. Download, install and configure Apache 2.2.17

Download windows installer from here

Installation should go without any problems so I will jump to the Apache configuration for PHP:

Open Apache configuration file (default location C:\Program Files\Apache Software Foundation\Apache2.2\conf\Httpd.conf) with any text editor.

To enable Apache processing of PHP pages find a line similar to this: 

DirectoryIndex index.html

and edit it to something like this:

DirectoryIndex index.php index.html

You’ll also need to permit the use of .htaccess files in any directory, so search for an AllowOverride setting and change it from None to All

Copy all dlls from C:\Php\dlls to the Windows system directory (default C:\windows\system32). Look for the section of Apache’s configuration file that contains AddType commands, and add this one: 

AddType application/x-httpd-php .php

Copy C:\Php\Php.ini-recommended to your Windows\system32 directory, rename it to Php.ini, and open it in a text editor. Edit the lines that set doc_root, extension_dir, and session.save_path so they look like the following: 

doc_root = "C:\Program Files\Apache Software Foundation\Apache2.2\htdocs"

extension_dir = "c:\php\extensions"

session.save_path = "c:\temp"

You’ll need to create C:\Temp if it doesn’t already exist.


The next two steps are to enable Apache to run PHP programs as modules.

First, copy C:\Php\Php4ts.dll to your Windows\system32 folder. 

 Download php4apache2.dll file from here

(note that the default file php4apache2.dll which comes in the php package won't work with apache 2.2 so you will have to download the file in the link above, if the link is no longer valid - contact me I still might have a copy).


Look for the LoadModule section in Httpd.conf and add this line:

LoadModule php4_module modules/php4apache2.dll


3. Downloading, installing and configuring MySQL

Download MySQL 5.1.53 from here

After installing it, open configuration file (default location C:\Program Files\MySQL\MySQL Server 5.1\my.ini) and add the following line:


when you change the server to use old-passwords, any existing accounts need to have their password changed to the old password format. Example:

mysql> SET PASSWORD FOR 'username'@'hostname' = OLD_PASSWORD('mypassword');

Where 'username'@'hostname' is the account and client host you use, and 'mypassword' is the password you want to use for that account.


You need that last step to enable a PHP4 application to connect to a MySQL 4.1 or later, else you will probably see the following message: "Client does not support authentication protocol"


4. Testing


First of all after saving all previous changes restart the Apache server.

Now to see if we set everything correctly navigate to the htdocs folder (default location: C:\Program Files\Apache Software Foundation\Apache2.2\htdocs) and create 2 php files there.

First one to test php - name it index.php and add following line to it:

<? phpinfo(); ?>

Save the file and navigate to http://localhost on you broswer, if you see PHP information - congrats PHP and Apache are setup correctly.

Name second file testsql.php and add following code to it:


$db_link = mysql_connect ("localhost", "root", "mypassword") or die ("Connection Failed!");

if($db_link) { echo "<b>
Connection to MySQL server initiated successfully!</b>"; }



Save it and navigate to http://localhost/testsql.php on your browser to see if connection is successful.






Errors encountered:

httpd.exe: Syntax error Cannot load php4apache2.dll into server: The specified module could not be found. - Solved by replacing php4apache2.dll to one downloaded

Warning: mysql_connect() [function.mysql-connect]: Client does not support authentication protocol requested by server; consider upgrading MySQL client - Solved by adding "old-passwords" line to MySQL configuration file my.ini

No comments:

Post a Comment