Go Back   TechArena Community > ARENA > Guides & Tutorials
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Thread Tools Search this Thread
Old 13-12-2007
Join Date: Dec 2007
Posts: 365
Learn how to Install Apache2 MySQL and PHP on Windows

This tutorial is 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 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 have only been tested on Windows XP. There may need to be some changes made for older versions of Windows so ask here if you need any help.

Installing the latest stable release of the Apache 2.0 series

STEP 1. Download Apache 2.x

Go to http://httpd.apache.org/download.cgi 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 contiunue 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:

<html> <body> Apache is running... </body> </html>

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 for help. 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 http://www.php.net/downloads.php 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 the 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 which should be located at C:\Apache2\conf\httpd.conf.

Now search For:

#LoadModule ssl_module modules/mod_ssl.so

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 as phpinfo.php in your htdocs directory and browse to http://localhost/phpinfo.php to see if it's working. The .php extension is very important.

Step 3. Download and install MySQL

Go to the mysql downloads page at http://www.mysql.com/downloads/index.html 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:
PHP Code:
/* 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 mysql create database MyDatabase;

The results would look something like this:

C:\>cd c:\mysql\bin C:\mysql\bin>mysql

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. If you want to learn how to create separate MySQL users and more you check out the MySQL manual http://dev.mysql.com/doc/mysql/en/index.html
Reply With Quote
Old 31-07-2009
Join Date: Jul 2009
Posts: 2
smile Re: Learn how to Install Apache2 MySQL and PHP on Windows

the php 4 is a little older now for php5 and apache 2you would have to use

LoadModule php5_module "c:/php/php5apache2.dll"

for apache 2.2 or higher LoadModule php5_module "c/php/php5apache2_2.dll"

Also There's a good article that shows how to add mysql support for php5 here's the link Install php on windows

Hope it will solve problems for ppl who read this.

Last edited by Yashk : 31-07-2009 at 03:04 PM. Reason: External link Removed
Reply With Quote

  TechArena Community > ARENA > Guides & Tutorials
Tags: , ,

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads for: "Learn how to Install Apache2 MySQL and PHP on Windows"
Thread Thread Starter Forum Replies Last Post
Unable to install MySQL and MySQL Workbench on Linux mint 10 Zared Windows Software 4 13-01-2011 01:08 AM
How to install Apache2 and PHP on Fedora 12 Kanakpriya Operating Systems 5 20-02-2010 01:43 AM
Install Apache and MySql on windows Enriquee Networking & Security 5 05-01-2010 04:32 AM
Mysql Error : Can't connect to local mysql server through socket ' var lib mysql mysql.sock' 2 roshan45 Software Development 3 07-11-2009 09:36 PM
Install PHP5 On Fedora 10 and Apache2 with mod_fcgid mauricio Guides & Tutorials 5 16-03-2009 10:35 AM

All times are GMT +5.5. The time now is 09:37 PM.