Webservers on Windows - Apache, Mysql and Php Installation

WAMP installation for dummies


After yet another post on php.windows mailing list by users on "how do make mysql work" and viewing some (often incorrect) installation instructions I've decided to do a "Windows Installation for Dummies" for people who seem to have trouble with WAMP (Windows, Apache, Mysql, Php) installs. I'll also include some supplementary information for IIS and PHP, alternate dbs, and adding php extensions.

There are many open source projects that are available on windows. Some of the more famous made their way on linux and unix servers first, and have since migrated to other platforms. This deals with a well known combination commonly referred to as LAMP (Linux, Apache, Mysql, Php [or Perl depending on who you talk to]). These programs together make a powerful, easy to use webserver. WAMP (Windows, Apache, Mysql, Php) is a similiar acronym that is slowing becoming popular as the windows world finds out about great open source programs. This article attempts to walk you through installing the programs on windows quickly and efficiently, and in ways that make upgrading painless.

Five steps to a webserver

  1. Prepare OS
  2. Download Software
  3. Install Apache
  4. Install Mysql and Admin Tools
  5. Install and configure Php

Step One - Prepare OS

OS stands for operating system. Before you start throwing a bunch of new programs on your computer you need to make sure you've done the proper preparation. First of all, you'll need a copy of windows installed on your computer. Don't try this on windows 98, 95 or ME unless you're insane - you really need at least windows NT, XP or newer is recommended. Make sure windows is installed properly and not infected with viruses, spyware, or other undesirables. Also apply all service packs and windows updates! You'd be surprised how many people try to put software on a messed up or non-patched windows install and then complain when things don't work. It might also help to defragment your hard drive, make sure you enough memory (RAM) and storage space (on your hard drive) to accomodate the new load you'll be applying.

Apache will run two items in the task manager - one around 15M, one around 23M, Mysql will run one 10-12M for a rough memory estimate. Remember that although apache and mysql don't take up much space on disk, they may take up a lot of space with things like ever growing database tables, lots of session files, even large transactions. Plan for the space you'll need. Once you have a functioning, fully patched copy of windows and enough hard drive and ram space for the new programs then we can move on to the next step

Step Two - Downloading Software

Since you already have the W of WAMP ready, you need to download the other three parts. If you would rather run IIS (Internet Information Server - Microsoft's server solution) - perhaps you need to use ASP pages for another project or something - you can skip this download. First the apache server. Currently there are three branches (basically three versions) of apache available. The 1.3.x branch (version 1.3.34 as of today), the 2.0.x branch (2.0.55 as of today) and the beta 2.1.x branch (2.1.8-beta as of today). Why are there three versions? The 1.3.x branch is the old, very stable version that was first designed on linux. The 2.0.x branch is an improved version that runs much better on windows. The 2.1.x is beta - that means it's still in development and you shouldn't use it on a production server, but if you want to try it at home and find some bugs you're welcome to. You'll want the "best available version", currently 2.0.55 from http://httpd.apache.org/download.cgi - get apache_2.0.55-win32-x86-no_ssl.msi. That's the windows installer version.

Next you'll need mysql - although you can use another database program instead. If you already have a license for microsoft sql server, php can interact with that just fine. You can also use oracle, postgresql, firebird, interbase, and many other databases, so if you're used to another database's quirks, don't think you HAVE to use mysql because you're using php. However, Access is NOT a good choice for a webserver database - php has a flat file solution (sqlite) if you'd prefer that to a full featured database server.

If you'd like to use a different database you can skip this download.
Mysql has recently moved to "two editions" - much like redhat split out fedora. The website provides a brief summary of the differences between the two. Now that 5.0 is the offical version that's the one you should download - the 4.1 version will be phased out and the 4.0 and 3.23 branches are in effect dead. Unless you need the embedded version of the server, get the windows essentials installer - you'll need to scroll down the page and choose a mirror.

You have two choices for managing your mysql server, web software or windows management tools. If you're going to be doing remote management a web software package will be the most logical choice (see the appendixes), if not mysql provides two windows gui management tools. Mysql Administrator has server health monitoring, performance optimization, backup capabilities, server information, replication status, server logs, service control, user management, and database browsing with a gui tool. It is cross platform, but was originally windows only. Mysql Query Browser is a visual query program and can be used to manage data. I found the query browser interface to be a bit strange at first, but once I figured out how everything worked I enjoyed using it.

Last, but not least, you'll need php. Like apache, php has two main branches, the 4.x branch and the 5.x branch. Most php software currently available is written for 4.x and most production servers still use this version. The 5.x branch has many improvements, including a new object/class system. However, the current 5.0.x versions of php tend to be slow and exceptionally buggy on windows and I wouldn't recommend them. If you'd like to use php 5 features, probably your best bet would be to use 5.1 snaps. Snaps are "snapshots" compiled from the source code on a regular basis. Although they usually work great they can be dangerous on a production server. 5.1 is currently in RC status - that is there have been several "release candidates" completed, and hopefully the official 5.1 release will be soon. If you want php4 make sure you download the PHP 4.4.1 zip package , not the installer version. For php5 versions, use snaps.php.net and download the one of the links under Win32 Package and Latest CVS (5.1.x-dev). There are also pecl (php extensions) dll's available. (see the appendixes for more information)

Now, you should have an apache msi, a mysql msi, a php zip file, and possibly one or two msi's for mysql management tools. On to the next step

Step Three - Installing Apache

Apache is installed with an msi package - basically you double click the downloaded item and follow the instructions. Below is a step by step walk through the installer. If you already have another server (such as IIS) running on your machine, make sure it's not currently running - or if it is running that it's not running on port 80. If you have an earlier version of apache already on your computer, you have to uninstall it first. Annoying, but you'll live. Make sure you have administrator priviledges, double click to start the installation.

First Screen
Click Next

License Agreement
This screen is the license agreement, you may want to read the terms, or if you're like most people Choose I Accept and Click Next

Basic Information
This screen contains some basic information about the apache project. You may wish to read over it to learn more. Click Next

This is the first step where you're required to enter some information. First of all, it's preferred that you install for all users as a service - the default setting. If this is a test or development server and will only be used locally, the settings above will work fine. If this is a production server, you should enter the domain name of the server in the top two boxes. For example, google would use google.com and google.com. The administrator's email address is used on error pages and should be set to an account that is read by the person who will manage the server. After all three text boxes are filled in properly Click Next

Installation Type
If you're reading this guide, you're not an advanced user, Typical will be fine Click Next

Installation Location
The default location should work fine, it's usually a good idea to follow microsoft's lead and keep your programs in program files. There are a few exceptions to this rule. If you have multiple hard drives and want to keep all your server files on one drive, or if you simply don't have enough room you can move the location, however windows doesn't always cooperate. Click Next

Perform Installation
You should be all set now. Click Install

Wait patiently while the installation occurs - a command window (black box) may pop up, just ignore it.

The installation is complete. Remember if you have firewall software installed that you must open port 80 to let the server function properly. Click Finish

Now let's test the installation. Visit your website with a browser. If you used the settings above try http://localhost , otherwise use your domain name. You should see a page like the one below. If you had apache installed previously, your old configuration settings will still be used.
Test Page

Server Management

If you look on the right side of your taskbar you should see a new icon. If you right click on the feather you should be able to start, stop and restart your server. The is the apache service monitor. If you double click the icon you can open the manager. Apache Service Monitor. You'll also find a new item in your programs menu with management, log viewing, and control options. There is still some additional configuration to do for the server, but we'll wait until after we've installed php.Apache Management

Step Four - Installing Mysql

Mysql is also installed with an msi package - basically you double click the downloaded item and follow the instructions. Below is a step by step walk through the installer. If you wish to install a database other than mysql, please see the Appendixes. If you have an earlier version of mysql already on your computer, mysql 5 will be installed alongside the earlier version. This can eat computer resources, so you may want to backup your databases and then remove the earlier mysql version. Make sure you have administrator priviledges, double click to start the installation.

First Screen
Click Next

Installation Type
If you're reading this guide, you're not an advanced user, Typical will be fine Click Next

Installation Confirmation
Like apache, the default location should work just fine.Click Install

Wait patiently while the installation occurs.

Sign Up
The installation is complete. You can sign up for a mysql account if you wish, but most people can just Skip It. Click Next

Although the server is installed, no database instances are configured yet, check the box to use the configuration manager to set one up. Click Finish

Server Instance Configuration

Begin Configuration
Let's start the configuration. Click Next

Configuration Type
You can do a default configuration, but a Detailed Configuration gives you more choices.Click Next

Server Type
Production servers should choose Server Machine , testing and development servers should choose Developer Machine Click Next

Database Type
Multifunctional Database should work for everyone. Click Next

The default location should work just fine.Click Next

How many concurrent connections you'll make to the database. Production servers should probably use Online Transaction Processing. Test and development servers can turn this number way down with Manual Setting. I keep mine at about 5. Click Next

You can turn off TCP/IP networking on windows, but named pipes are not always cooperative. It's easier to just enable it. Also leave Strict Mode enabled. Click Next

Character Sets
Since the internet is international and you never know what people are going to put in your database, it's usually safer to choose Best Support for Multilingualism (UTF8 default charset) Click Next

Install it as a windows service, you an change the name to anything you like. Php needs the bin directory in Windows Path so it uses the right libmysql client.Click Next

Don't create an anonymous account, but make sure you don't forget the root password you set. Click Next

Ready to Execute
Time to start the configuration. Click Execute

Configuration is Complete. Click Finish

Database Management

System Tray Monitor
If you'd rather use phpmyadmin to administrate your database, see the appendixes, otherwise install Mysql Administrator and Mysql Query Browser. You shouldn't have to make any decisions, clicking next will install them properly. Mysql Administrator includes a very useful product called the Mysql System Tray Monitor. If you put it in your startup menu you can start, stop and monitor mysql instances like you do with the apache monitor. Right click on the icon for extended options. You will find a mysql option in your programs menu with shortcuts to administrator, query browser, instance configuration wizard, and command line mysql tools.
Start Menu

Test Database

You can test your installation by using the command line client shortcut and entering the password you set for root.
Start Menu

Step Five - Installing Php

The first step in installing php is unzipping the files. Many people recommend putting it in c:/php - but I think that causes as many headaches as it solves. It's just as easy to put it in c:/program files/php. So unzip the contents and move the folder to the location you prefer. Next you need to add that location to your path variable. To do this, you need to find System Properties for your computer. Here are instructions for XP. You can either visit control panel->system settings or right click on my computer and choose properties. Choose the Advanced tab.

System Properties
Click Evironment Variables

Find Path
You may have more or less environment variables. Look in the lower box for the one called Path Click Edit

Edit Path
Add a semicolon to the end of the current path and add on your path to php - mine is c:/program files/php Click Ok until all the windows are closed.

There are two files we need to edit, httpd.conf which is the configuration file for apache, and php.ini, which is the configuration file for php. First you need to decide where your Document Root is going to be for your webserver. This is the place where you'll store all the files for websites. The default is "C:/Program Files/Apache Group/Apache2/htdocs". Head to Start->All Programs->Apache Http Server 2.0.55->Configure Apache Server->Edit the Apache httpd.conf Configuration File This will open up the apache configuration file in your text editor. Notice all the # signs? That means that line is a comment, and the program should disregard it.

Editing Apache Configuration

Scroll down until you reach a list of "Load Module" items. At the bottom of this list add LoadModule php5_module "c:\program files\php\php5apache2.dll" or LoadModule php4_module "c:\program files\php\sapi\php4apache2.dll"

It should look like this
#LoadModule usertrack_module modules/mod_usertrack.so #LoadModule vhost_alias_module modules/mod_vhost_alias.so #LoadModule ssl_module modules/mod_ssl.so LoadModule php5_module "c:\program files\php\php5apache2.dll"

Notice that the path is c:/program files/php because that's where I put my php files. Notice that I quoted the path - this is because I used backslashes and the path has a space in it. It's good practice to quote paths on windows. I also removed the # from rewrite_module because that's something I use a lot in my programming.

Scroll down some more until you come to DocumentRoot - this is the place where you'll store your webpages. Simply place the absolute path to where you want your webpages to be stored, or keep the default if you like. If you change this value, you must also change the value of

# # This should be changed to whatever you set DocumentRoot to. # <directory "c:/same/as/documentroot"&rt; </directory&rt;

Continue down until you find the line
DirectoryIndex index.html index.html.var
and add index.php to that list.

Finally find the area with AddType declarations and add this to the end
AddType application/x-httpd-php .php

PHPIniDir "C:\program files\php"
Notice that your PHPIniDir may differ depending on where you put php.

Editing Php Configuration

Now you need to visit your php directory - mine is c:/program files/php. Copy php.ini-recommended and rename it php.ini. Then open it up in a text editor. Notice all the semi-colons? They work like the # did in the Apache file, they mean the line is a comment.

If you are NOT running a production server, you probably want to change display_errors to on and log_errors to off. By default php errors will be logged to your apache error log. You need to scroll down to the "Paths and "Directories" section. There are a lot of other useful settings, you can see the php manual for more information. For now we'll only change the ones that windows needs to work properly. extension_dir needs to be set to the directory that holds all php extensions. In php5 this directory is name ext, in php4 it's named extensions.
; Directory in which the loadable extensions (modules) reside. extension_dir = "c:/program files/php/ext"

Next you need to head down to the long list of Windows Extensions. In order to use the mysql or mysqli extensions you MUST have the line(s) extension=php_mysql.dll and/or extension=php_mysqli.dll uncommented. Finally move down to the [Session] module area and find session.save_path - it should be set to a location where apache can write - usually c:/temp although some use other locations.

Test Installation

First, restart your server. If you get an error, you may need to restart your computer - windows gets a little nutty over changing path variables. If you still get an error, try checking your syntax Head to Start->All Programs->Apache Http Server 2.0.55->Configure Apache Server->Test Configuration Often a silly typo can be the problem. Next create a blank file and name it info.php. Place one line in the file ?php phpinfo()?> and put this file in your Document Root. Now head to http://localhost/info.php (or whatever your domain name happens to be). You should get a nice page with information about your php installation.

Php Info

Congratulations - You're done...kind of

One thing about open source projects is they fix bugs quickly and often. You don't get once a month rolled updates. However, updating should be fairly painless. With apache - you'll need to download the new version, then uninstall the old and reinstall the new. However, your original httpd.conf will be used so you don't have to redo any settings. Mysql you can use windows installers to update right over the original programs. Php - stop the server, unzip the new files directly over the old files and restart the server. But make sure you update when security holes are fixed!

The Appendixes

  1. IIS and Php
  2. Other Databases
  3. Php settings from Apache
  4. PECL
  5. phpMyAdmin

IIS and Php

IIS (Internet Information Server) is NOT the best choice for windows servers but if you need to use it for some reason The Php Manualhas an excellent section on how to install. I'd personally recommended installing php as an isapi - you trade some stability with php as a cgi for a great increase in speed and flexibility with the sapi.

Other Databases

Php has many database extensions that can be used. The great limiting factor seems to be the number of php software items which only work on mysql. There are "abstraction layers" for php. Pear DB, Pear MDB, Pear MDB2 and ADODB just to name a few. Installing new php database extensions involves editing the php.ini file to allow the extension you wish to be activated, then restarting the server. PDO, Php data objects, is a new feature of php 5.1 and should make database access a much easier task.

Php settings from Apache

You can change some php settings from your apache configuration file or .htaccess files. Why would you want to do this? The most practical application is when using large numbers of virtual hosts. A look at php ini directives will show which ones can be changed with .htaccess, which can be changed in the script, and which can be changed with httpd.conf.


Pecl is the php extension repository. Php is moving away from having large amounts of functionality bundled in the core and instead moving extensions into pecl. Once considered "siberia" for extensions, PECL now has a large number of useful active projects, and even has automatic creation of windows .dlls for all the current branches. Installing a pecl extension on windows is fairly simple, download the right .dll, put it in your php extension directory, add the extension name to list in the php.ini and restart the server.


phpMyAdmin is a very popular php way to manage mysql databases. You'll need to download the latest version, place it somewhere in your document root and edit config.inc.php. You should then be able to login using the username root and the password you set when you configured your database instance.


Lew Eichorn

We have had to copy libeay32.dll, libmhash.dll, libmysql.dll, ssleay32.dll, yas.dll from php directory to either the apache2 bin directory or windows system32 directory in order for php to find corresponding extensions.

2005-11-28 4:35 am


Then you didn't read the directions carefully enough - add the path to the php directory to your path environment variable AND RESTART THE COMPUTER - I know a lot of people say you don't have to restart after changing PATH but I can't get that to work on windows XP pro - restarting fixes it. Also if you have problems with php_mysql.dll or php_mysqli.dll make sure the path to libmysql.dll comes BEFORE the path to your php dir in the path variable, otherwise the wrong libmysql.dll will get used.

2005-11-28 5:36 am


Do you know anything about adjusting the cpu utilization of apache under windows? Some data processing PHP scripts I've been running are executing rather slowly, and when I check the task monitor, the CPU usage never goes above 10%rnrnI'd like to see apache use 100% when running these scripts..

2006-07-10 4:35 am


Have you a way to connect to PICK/UNIVERSE databases with php?

2006-08-11 5:48 pm


I don't know that much about it but according to google theoretically you can connect to PICK/UNIVERSE with an odbc driver - so you'd have to install the driver in windows and create an odbc dsn and connect to it via php's http://us2.php.net/odbc functions - but no, there is not a native way to connect to that database using php

2006-08-11 7:02 pm


Hi! I setup SSL/TLS on apache 2.0.rnIts working fine apache only listen on 443 port for incoming connections. My question is:rnHow to config apache , for example when user type www.dome.com to automatic redirect him to port 443 and https connection. Now when i use www.domain.com he dont display anything because apache don listen on 80.rnCan you help me, please? Thanx :)

2006-12-18 5:34 am

Post a Reply