Quick Steps to Install Apache, MySQL, and PHP in Windows

There are plenty of tutorials for WAMP installations (Windows, Apache, MySQL, and PHP), but I don’t know of any that have quick, easy-to-follow directions for someone familiar with Web development, but not necessarily with getting a local installation started.

UPDATE: The following instructions are no longer up to date. To install a WAMP server, try using XAMPP.

Installing Apache

The latest version of Apache can be found at http://httpd.apache.org/download.cgi. Unfortunately, the Windows version is not always up to date with the Unix version, so you’ll have to scroll down the page until you find the most recent Win32 version. You should notice a few download options for Win32 (“source” or “binary” and “without crypto” or “including OpenSSL”). Unless you plan on using SSL, download the binary version without crypto (it’ll be an MSI file).

After the download completes, open the file and run it. Click “Next”, accept the terms and conditions, and continue through any other screens until you’re asked for some server information. Enter localhost for both the network domain and server name fields, and use whatever e-mail address you like for the administrator’s e-mail field.

If you want Apache to run, even when you’re not logged in, leave it set to run as a service. However, if you’ll only be using it with an occasional project, change it so that it has to be manually started. The “typical” installation should be fine, as well as the default destination folder. After installation completes, click “Finish.”

To start Apache (assuming it isn’t running as a service), you can navigate to the “bin” folder (found at “C:\Program Files\Apache Software Foundation\Apache2.2\bin” in most cases) and run the “httpd.exe” application. Personally, I run it from the command line. To do this, open a command prompt, and update your PATH environment variable (e.g. SETX PATH "%PATH%;C:\Program Files\Apache Software Foundation\Apache2.2\bin"). Close the command prompt, reopen it, and now you should be able to launch Apache by simply typing httpd.

To make sure everything is working, visit http://localhost/, and you should see a blank page with the words, “It works!” If not, try http://localhost:8080/ — 8080 is a common port used if the standard port 80 is unavailable. The Web page being displayed is found in the “htdocs” folder of your Apache install.

Installing PHP

Visit http://www.php.net/downloads.php and download the Windows binaries and source (Thread Safe, ZIP format) of the latest version. Extract the ZIP files to a “PHP” folder in your “Program Files” directory (e.g. “C:\Program Files\PHP” — you’ll need to create the “PHP” folder). After extracting the files, make a copy of the php.ini-development file and rename it to php.ini.

Now, we need to make some configuration changes for Apache to recognize PHP. Open the “httpd.conf” file in the “conf” folder of your Apache installation, and search for a list of lines starting with “LoadModule”. After those lines, add the following:

LoadModule php5_module "C:/Program Files/PHP/php5apache2_2.dll"

Next, look for the <IfModule mime_module> section of httpd.conf and add the following just before it’s closing </IfModule> tag:

AddType application/x-httpd-php .php

Finally, add the following to the very end of your httpd.conf file:

PHPIniDir "C:/Program Files/PHP"

To verify that PHP is working, create an index.php file in the htdocs folder, and add the following to it:

<!doctype html>
<title>PHP Info</title>
<?php echo phpinfo(); ?>

Visit http://localhost/index.php (or http://localhost:8080/index.php), and you should see some tables displaying your current PHP and server settings. Now we’re ready to install MySQL.

Installing MySQL

First, download the MySQL Community Server MSI file from http://dev.mysql.com/downloads/mysql/. The installer is fairly simple — choose “Typical” when prompted for the setup type, and it should complete shortly afterward. Check the box to run the configuration wizard after the install. The default settings should suffice for most of the screens, but you’ll need to choose a memorable root password before finishing.

As for MySQL, that’s it. No additional setup needed. Create a database and start programming — you’re local dev machine is ready to go!

Conclusion

Hopefully, you now have a working WAMP installation. I purposely left out a lot of configuration options, as the purpose of this guide was to get you up and running as fast as possible. If you notice any mistakes or have any issues, feel free to post them in the comments below.