November 23rd, 2010

Setting up an Apache, MySQL and PHP Server on Windows (WAMP)

Setting up a WAMP (Windows Apache MySQL and PHP) server is the beginning of setting up your development environment on Windows. This how-to describes a minimal WAMP installation to get you started developing for the web on Windows.

— Matt Fellows —

Download Apache, MySQL and PHP

Apache 2.2
PHP (Don’t download the installer )
MySQL 5.0 (Windows Setup)

Installing MySQL

– If you don’t have MySQL and want to install fresh – skip to “Upgrading MySQL”
– If you already have a version of MySQL and don’t want to change you can skip this step.
– If you already have a version of MySQL and WANT to upgrade follow these steps:

Upgrading MySQL

– Open the command prompt and type the following command to backup all of the MySQL databases:

mysqldump -u<username> -p<password> > c:\<path-to-backup-file> (e.g. mysqldump -uUser -pPassword > C:\mysqlbackup.txt)

where <username> and <password> are your adminstrator’s username and password and path-to-backup> is the backup filename

– Make sure this file is saved somewhere safe and obvious because we will need it later
– Now remove MySQL by opening control panel > add remove programs and selecting your version of MySQL

Installing MySQL

  1. Run the installer and choose “Complete installation”
  2. Afterubg signing up to MySQL, choose “Configure your server now”
  3. Choose “standard configuration”
  4. Ensure that the Install as Windows server, Include Bin Directory in Windows PATH and Launch the MySQL Server automatically options are checked and that the service name is MySQL. These options ensure that MySQL starts up automatically as a service when your machine boots, and that you can run the mysql programs without navigating to their directory. Enter a password to access MySQL as an administrator. Caution – Do not check “Enable root access from remote machines” unless you know what you are doing.
  5. Choose execute. If you experience any problems at this point, it is likely that you have an antivirus or firewall application that is blocking the connection to port 3306. To remedy this, you need to allow mysql access. Refer to your particular Antivirus solution to find out how to do this.

Restoring the pre-upgrade data

– Open the command prompt and type the following command to restore your MySQL backup:

mysql -u<username> -p<password> < <path-to-file> (e.g. mysql -uUser -pPassword < c:\mysqlbackup.txt)

MySQL is now installed and restored!

Install Apache

  1. Run the apache installer
  2. Enter ‘localhost’ for the “Network Domain” and “Server Name”
  3. Enter your email address for the “Adminstrator’s Email”
  4. Choose a typical installation and choose install. Again, Windows firewall or your antivirus-may block apache from connecting to a port. Choose unblock or manually change the antivirus settings to allow apache to connect.
  5. If all went well, open up a browser and navigate to “http://localhost”. If you see a “It works!” then Apache is setup and ready to go!

Install PHP

  1. Unzip the PHP download to something like c:\Program Files\PHP. I will assume that this is the directory you have used from here on.
  2. Navigate to C:\Program Files\PHP
  3. Copy the file “php.ini-recommended” and name the new file “php.ini”. This is the configuration file for PHP.

Note: In the configuration file, any line beginning with a semi-colon ‘;’ is ignored and treated as a comment. Removing the semi-colon activates the command.

– If you would like PHP to display errors (useful for debugging) change the display_errors command to

display_errors = on

– To allow PHP to connect to MySQL you need to allow the MySQL extension, remove the preceding semi-colon’s from these two lines:


and set extension_dir to:

extension_dir = “./;C:\Program Files\PHP\ext”

Now move this file into the Windows directory i.e “C:\Windows\php.ini”.

Configure Apache to use PHP

– Open <path-to-apache>\conf\httpd.conf (i.e. C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf) and add the following lines to the end of the file:

# Load PHP5 module
LoadModule php5_module “C:\Program Files\PHP\php5apache2_2.dll”

# Tell apache about the PHP file type
AddType application/x-httpd-php .php

# configure the path to php.ini
PHPIniDir “C:\Program Files\PHP\”

– Navigate to <path-to-apache>\htdocs (i.e C:\Program Files\Apache Software Foundation\Apache2.2\htdocs)
– Create a file called index.php in this directory and enter the following code:

echo “<h1> Hello, i’m a PHP file! </h1>”;

Restart the Apache service by clicking on the little Apache icon in the system tray and choose ‘restart’.

Open a browser and navigate to “http://localhost/index.php” and you should see a message saying “Hello, i’m a PHP file”

You have now installed a WAMP on your machine!