home contact us scripts page
contact us scripts product
online contact us script demo
buy now contactus script
contact us section

Tutorial 7: Installing Apache, PHP, MySQL on a Windows 98/2000/XP Computer


This tutorial shows you howto install Apache, PHP and MySQL on a Windows 98, 2000 or XP system.

Few words...

It is known that PHP and MySQL are until now the best combination of programming languages for the Web. The strong point is given by the fact that both of PHP and MySQL are Open Source, anybody could use it for free. And Apache is most powerfull, secure and of course most used Web Server. PHP and MySQL run on Windows and Unix/Linux platforms. For that reason design and implementation of a dynamic website could be done on both platforms.

PHP and MySQL run on boths but which is recommended?

Well, shortly: Windows for development, Unix/Linux for production. Every computer professional recomend that for two reasons: Windows is easyer to use, even by a newbie, but is not so stable and secure, and Unix/Linux is secure and of course stable. Also, on Windows you will find more development tools. But please keep in mind, nobody encourage the usage of Apache, PHP and MySQL on Windows Servers. Also before installing Apache Web Server on some windows systems please read the following documentation from Apache:

Installation instructions step by step

Step 1. Download Apache Web Server from the Internet

Go to: and download Apache Web Server. You must choose the version you want. The last version is 2.2.2, so we recommend you to choose that version. If you have external modules for Apache, if those modules are not compiled for that version of Apache then you must use the exact version. Some of this modules may be required if you want to install a complex PHP script, like a CMS (Content Management System) a buletin board (forum) or other complex PHP application.

Pay attention to that: before installing Apache if you are a ASP developer and use other web sever like Personal Web Server or IIS then you must close that websever, because usualy it runs on the 80 port, that will be used by Apache, otherwise it won't work.

After you've downloaded Apache, double click to install it. You will be asked to fill in the address of your webserver, at this point fill in "localhost".

Step 2. On Windows click on Start button, choose Run, and type "cmd".

After that a terminal window will appear. There type the following commands:

cd c:\program files\apache group\apache\bin
apache.exe -k install
apache.exe -k start

If first command is not working see where apache is installed and type:
cd apache_installed_path/bin

Step 3. Testing the Installation of Apache

Ok, We have installed Apache, now is time to test the proper working of it. Open your Web Browser and type at address: http://localhost and press enter. After that a page shoud load into your browser with a message: "The Apache server is now installed on this web site!". If you see this message then you've succesfuly installed Apache Web Server.

Installing Apache Web Server is an important step in getting to work your Apache/PHP/MySQL system. If your Apache installation failed, verify to not have other web server running. Also check httpd.conf file located in the directory where you installed Apache.

You still cannot make Apache to work, visit Apache Website ( More information about similar problems you yours coud be found on Apache Mailing Lists (

Step 4. Download PHP from the Internet and configure it

Go to download page of PHP: and download the Windows Binaries version.
The file you've downloaded is a zip archive. You must unzip it and copy in a directory for example in c:\php4win.

Create another directory where all your work file (php sourcecode) will be holded. This directory coud be for example c:\phpwebsite.

Copy the file c:\php4win\php-dist.ini from c:\php4win directory (where you extracted the zip archive) to c:\php4win\php.ini file.

Edit c:\php4win\php.ini file with an text editor (notepad for example) and modify the values doc_root, and extension_dir like in the following example:

; paths and directories
doc_root = "c:\phpwebsite"
extension_dir = "c:\php4win"

Copy php.ini and php4ts.dll in c:\windows (or c:\winnt, if you've installed windows in winnt directory).

Delete php.ini file from c:\php4win directory.

After this PHP is installed into your system.

Step 5. Configuring Apache to work with PHP

Even if Apache Web Server is installed it is not configured to work with PHP files (apache knows only to respond to requests from static html files). In order for Apache to work with PHP we must edit the httpd.conf file which is the Apache configuration file. To do that find and edit httpd.conf file, located in C:\Program Files\Apache Group\Apache\conf\httpd.conf:

Find lines that contain DocumentRoot and Directory and change those lines like in the following example:

DocumentRoot "C:/phpwebsite"


<Directory "C:/phpwebsite">

After that, find line that contains: application/x-tar .tgz and after that add the following lines:

ScriptAlias /php4/ "c:/php4win/"
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
AddType application/x-httpd-php .php4
Action application/x-httpd-php "/php4/php.exe"

Carefuly make all modifications. Save the file and restart Apache.

Atention! Apache uses unix style slashes, so you must use "/", instead of "\". This is true only for Apache httpd.conf file, not for php.ini file. So please be carefuly with that.

Step 6. Verify working of Apache with PHP

Create a test.php file with the following content and save it in c:\phpwebsite:


Open your browser and type: http://localhost/test.php. You shoud see a webpage with all informations about PHP functions and options available.

Step 7. Download MySQL from the Internet

Go to and download Windows version. Depending on the version you've downloaded you must unzip into C: drive then double click on setup.exe.

After you have installed MySQL, start MySQL service (server). When developing PHP application that uses MySQL, this service must be always started.

To start mysql service go to C:\mysql\bin and launch mysqld.exe (you could create a shortcut on the desktop for that).
If you want to be sure that the MySQL service is starting properly, first time, for debuging purposes is good to launch mysqld.exe from command line:

Press Start / Run, type cmd, in cmd prompt type:
cd c:\mysql\bin

Step 8. Testing working of PHP with MySQL

Well, this is the last step in configuring your system to work with Apache, PHP and MySQL. For that we we'll write a php code that connect to our MySQL database server, create a database and insert into that database a record. After that our program will display the records from MySQL database.

Here is the program (copy-it into c:\phpwebsite):


mysql_query("create database testing_database");
mysql_query("use testing_database");
mysql_query("create table my_record(name varchar(60))");
mysql_query("insert into my_record(name) values ('John Doe')");

$sql_query = mysql_query("select * from my_record");
while ($row = mysql_fetch_array($sql_query))
print ("Added record: ".$row[name]."<br>");

Run this script. Press refress button from your browser. At every refresh a record containing John Doe name must be inserted into the database. If it does then your configuration is succesfuly.

Of course this is the basic instalation. But is a complete one. In time maybe you will need other things. For example when installing complex script warnings might appear on the screen. Or when trying to upload files from your scripts uploading is not working for files larger than 2mb. In those situations you must modify php.ini from c:\windows or httpd.conf file acordingly, depending of the error. You must find what variable shoud modify and from where (php.ini or httpd.conf).

If you do all steps exactly as in this Tutorial you must have no problems installing Apache, PHP and MySQL.

I wish you good luck with your Instalation!

If you found this tutorial useful you might be interested to read the following:

PHP Form image verification
PHP Create Image Thumbnail
PHP Form Image Upload
PHP print random image from a folder Count Words in a string using PHP