View Full Version : HOW TO Install Apache PHP and MySQL on Windows

Hopefully someone will find this tutorial useful. It's meant to show you how to install and set up the latest stable release of the Apache Web server, PHP, and MySQL to run on your local Windows machine for local offline testing and development. This can save you a lot of time and make learning and developing a lot easier.

These steps should work for setting up Apache 2 on most versions of Windows including Windows 98, Windows ME, Windows 2000, and Windows XP, but they've only been tested on Windows XP.

Installing the latest stable release of the Apache 2.0 series

STEP 1. Download Apache 2.x

Go to and scroll down to where you see Apache 2.x.x is the best available version. Just beneath that you'll see where it says Win32 Binary (MSI Installer): apache_2.x.x-win32-x86-no_ssl.msi [PGP] [MD5]. Download the apache_2.x.x-win32-x86-no_ssl.msi file and save it to your desktop or another location on your computer.

Step 1A. Install Apache 2.x
Browse to the location on your computer where you saved the apache_2.x.x-win32-x86-no_ssl.msi file that you just downloaded. Next, double click on it to open it up and continue through the installation by clicking Next until you come to the screen that says:

Server Information
Please enter your server's information.

Enter "localhost" without the quotes for both the Network Domain and the Server Name input boxes. Enter any email address you'd like in the Administrator's Email Address input box.

Now continue through the installation by clicking Next and leaving all the default values selected until you come to a screen that says:

Destination Folder
Click change to install to a different folder:

Click the Change button and change the folder name from "C:\Program Files\Apache Group\" to "C:\" without the quotes. Click OK and continue through the installation until you're finished.

Step 1B. Running Apache
Depending on which version of Apache and which versions of Windows you're running Apache may have been started for you already when you completed the installation. If it is, you'll probably see an icon in your system tray indicating that it's running. If it's not, you can start it by going to your Start menu --> Apache --> Start Apache in console or something similar. Depending on your version of Windows a Dos console window may open and remain open while you're running Apache.

Next create an index.html file, here's a sample one for you:

Apache is running...

Save the index.html file in your "C:\Apache2\htdocs" folder. Now browse to http://localhost/ or ( to see if Apache is up and running and if it's displaying the index.html file you just created. If you see "Apache is running..." or whatever you put in your index.html file then Apache is working. If you get a blank page or something else, you may try going back over the steps again or installing another version. If you're still unable to get it working or have any questions ask here and we'll help you out the best we can. Your C:\Apache2\htdocs folder is where you'll need to save all your HTML and graphics files.

STEP 2 Download and Install PHP

Go to and scroll down to where you see
Windows Binaries. Download the zip package, not the installer. Save this file to your desktop or another location on your computer. Browse to location on your computer where you saved the file and unzip it to your C:\ directory. Make sure you have this folder in your C:\ directory. Next rename the folder to "php" without the quotes. Now open up the php INI-DIST File located in your php folder.

Search for:
doc_root =

Replace with:
doc_root = "c:\apache2\htdocs"

Search for:
extension_dir = "./"

Replace with:
extension_dir = "c:\php\extensions"

Now save this file as "php.ini" without the quotes in your C:\Windows folder.

Next locate the php4ts.dll file located in your C:\php folder and copy or move it to your C:\Windows directory. You can do this by simply copying and pasting the file into your C:\Windows directory.

Step 2A. Configure Apache to work with PHP

Open up your httpd.conf file and Search For:
#LoadModule ssl_module modules/

Just below it add:
LoadModule php4_module "c:/php/sapi/php4apache2.dll"
AddType application/x-httpd-php .php

Save the file and restart Apache. To test it you can create a php file, for example info.php with the following content:
<?php phpinfo(); ?>
Save this file with a .php extension somewhere in your htdocs directory and browse to http://localhost/phpinfo.php to see if it's working.

Step 3. Download and install MySQL

Go to the mysql downloads page at and scroll down to where you see MySQL database server and standard clients: Click on the Production release (recommended) version to go to the downloads. Scroll down to where you see Windows Downloads.

Click on the "Pick a mirror" link next to Windows 95/98/NT/2000/XP/2003 (x86). Scroll down and click on one of the links that is close to you to start downloading MySQL. Save this file to your desktop or another location on your computer.

Unzip the file to a temporary directory. You may have an option to Install Now if you're using a program like Winzip to unzip the files. If not just browse to the directory where you unzipped the files and click on the Setup program to start the installation. Select all the default options until the installation is complete.

After the installation is complete a window may open with a message that says "Create the mysql.ini file with default values and the user below." Go ahead and enter a username and password and click OK.

If the window doesn't open browse to your C:\mysql\bin folder and click on the MySQL icon(winmysqladmin.exe) to start the program. You can use this program to make changes to your mysql settings and start and stop the server.

Now you can test and make sure mysql is working as well as make sure you're able to connect with PHP by creating a php file, for example dbconnect.php with the following content:
/* Testing database connection */
$link = mysql_connect("localhost", "root", "")
or die("Could not connect : " . mysql_error());
echo "Connected successfully";
Save this file in your htdocs folder and browse to http://localhost/dbconnect.php to see whether it's working or not. If it is you should get a message that says Connected successfully. If you get any errors you may need to start MySQL which you can do by opening the winmysqlamin.exe file located in your C:\mysql\bin folder. You can use root as your username and just leave the password blank "" as in the example above in your scripts. If you need to create a database you can do so by going to your start menu --> run and entering cmd or dosprmpt in the input box. This should open up a DOS window. Next type the following commands pressing enter after each one:

cd c:\mysql\bin
create database MyDatabase;

The results would look something like this:

C:\>cd c:\mysql\bin
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 4.0.17-nt
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> create database MyDatabase;
Query OK, 1 row affected (0.00 sec)

That would create a database named MyDatabase, replace it with what you want to call your database. You can exit mysql and the DOS window by typing exit.