
This article will discuss in detail how to setup a local Windows Apache, MySQL, and PHP (WAMP) development environment.
Before proceeding, make sure you have at least 1GB of disk space available for the installation and have your Windows system up to date with the latest service packs. Also, it is recommended that you have at least 1GB of memory on your system and know how to administrate Windows services. This is so that you can turn services off to reclaim memory for your desktop computer use.
All application services will be installed on your Windows desktop system.
Download MySQL Community Server, Apache Win32 Binary without crypto (MSI Installer), and PHP MSI Installer.
It is recommended that you download the latest versions of each. At the time of this writing, this is MySQL 5.1, PHP 5.2.8, and Apache 2.2.11.
Look in the Windows start toolbar. The Apache Service System Tray Monitor should be installed. Click on it and turn on the server. Run your favorite browser and surf to http://localhost. If you see a "It works!" message, congratulations.
To make sure your internal domain name works, edit the /windows/system32/drivers/etc/hosts file and add the following:
127.0.0.1 localhost
127.0.0.1 imysite.com
127.0.0.1 www.imysite.com
Replace imysite.com with your internal domain name and save the file. Then, surf to http://www.imysite.com and http://imysite.com and make sure you get the same message.
It is recommended that you change the accessfilename to htaccess.txt instead of .htaccess to avoid any problems under Windows. It will also allow you to tweak Apache settings if you need to later. Go to your httpd.conf file and make the following change:
# Great for Linux/Unix but bad for Windows because of
# period in filename
#AccessFileName .htaccess
AccessFileName htaccess.txt
Then, create an htaccess.txt file and place all your Apache .htaccess directives, if you so desire. If it appears you are having difficulties getting your htaccess directives to be invoked, allow htaccess directives to be allowed.
Look for the directory directive and then change the override to "all":
# Its none by default
# AllowOverride None
AllowOverride All
Also, if you are working with websites that have a mixture of static html in say one site, and php in another, you may want to make appropriate directory index changes.
# I like to order static files first, then dynamic just in case
# name collision which would render static sites useless
DirectoryIndex index.htm index.php
Note (9/11/09):
Some versions of Apache may not require httpd-vhosts.conf. I tried version 2.0.63 recently and httpd-vhosts.conf did not exist. It appears that in versions 2.2 and above this is true. You can simply modify httpd.conf and place all virtual host configurations in there as described below.
Now we are going to setup virtual hosting. Virtual hosting allows for more than one domain to exist on the server. Go to the apache/conf/httpd.conf file and look for this line:
#Include conf/extra/httpd-vhosts.conf
Remove the pound sign so that it is enabled. Then go to apache/conf/extra/httpd-vhosts.conf and put in it the following:
NameVirtualHost *:80
ServerName www.imysite.com
ServerAlias imysite.com
DocumentRoot "c:/apache/htdocs/"
ErrorLog "logs/imysite.com-error.log"
CustomLog "logs/imysite.com-access.log" common
Create a HTML file and name it index.html. Restart the apache server from the system tray monitor and then surf to your site.
To add more domains, go to the HOSTS file and make additions. Also, add to the httpd-vhosts.conf file additional VirtualHost blocks:
NameVirtualHost *:80
ServerName www.imysite.com
ServerAlias imysite.com
DocumentRoot "c:/apache/htdocs/"
ErrorLog "logs/imysite.com-error.log"
CustomLog "logs/imysite.com-access.log" common
ServerName www.imysite2.com
ServerAlias imysite2.com
DocumentRoot "c:/apache/htdocs/"
ErrorLog "logs/imysite2.com-error.log"
CustomLog "logs/imysite2.com-access.log" common
ServerName www.imysite3.com
ServerAlias imysite3.com
DocumentRoot "c:/apache/htdocs/mysite3"
ErrorLog "logs/imysite3.com-error.log"
CustomLog "logs/imysite2.com-access.log" common
Note that we create the ServerName to be the www part and preface the site name with an "i" for internal. We also create a non-www server alias. Another important point is that the Document root points to the folder where Drupal's index.php is installed.
In the example above, mysite1 and mysite2 are Drupal websites and mysite3 will be a non-Drupal website because it has a DocumentRoot that won't be triggered by Drupal's index.php bootstrapr.
Bring up a DOS command prompt and type in the following:
mysql -u=usernamehere -p
Mysql will then prompt you for a password.
When the mysql admin program comes up, enter in "show databases;" and hit the enter key. There should be three databases installed (information_schema, mysql, and test).
If you desire, you can install the MySQL GUI Tools application which contains some nifty tools like the MySQL administrator, MySQL Query Browser, and the MySQL System Tray Monitor - highly recommended.
After completion you need to go back into httpd.conf and make some changes. The PHP installer does not add the application type extension. This is a bug in the installer. Look for these lines at the very bottom and duplicate what is here:
#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
PHPIniDir "C:/PHP/"
LoadModule php5_module "C:/PHP/php5apache2.dll" <--- filename
AddType application/x-httpd-php .php <--- add this line
#END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
You should now be able to run on your local Windows computer a complete WAMP development environment. Happy developing!