WampServer is full-fledged web environment that runs on Windows and works very much like your web hosting provider’s system, except that it is located entirely on your computer. With WampServer, you don’t even have to be connected to the Internet to do web design and development!
WampServer consists of the following components:
- Windows – You’ve already got this part! These instructions apply to Windows XP, Windows Vista, and Windows 7 (and may work on other versions, as well).
- Apache – The Apache web server is a free, open-source HTTP server that is used on over half of the web servers on the Internet. It is very well supported and has an active and helpful community, so it is quite easy to get help and find information about it.
- MySQL – MySQL is a popular free, open-source RDBMS server platform. As with Apache, it is widely used and has many users who share their experiences and tips. In addition, one of the great advantages of MySQL is that his native integration with Apache and PHP.
- PHP – PHP is also free and open-source and is a popular scripting language for developing dynamic interactive web applications. PHP is both easy to learn, even for beginners, and powerful.
You can think of Apache, MySQL, and PHP as three legs of a sturdy stool that stand on the foundation of Windows. You’ll undoubtedly hear about LAMP, which is similar to WAMP, except that the ‘L’ stands for Linux, which is a popular open-source server operating system that runs many web hosting systems.
To install WampServer, download the installation package from http://www.wampserver.com/en/download.php. Run the installation package and choose the defaults for each prompt. This will install WampServer to the c:\wamp folder (directory).
If you did not choose to launch WampServer after the installation completed, go ahead and run WampServer from the Start Menu: Start → Programs → WampServer → start WampServer. If you received any security warnings (very likely in Windows Vista and Windows 7) permit WampServer to run. These are warnings that WampServer wants to make updates to your system and to use network resources, which is normal since this is a web server environment! You’ll see an icon in the Windows system tray that looks like gauge or speedometer with a needle. It will show red, then yellow, and finally (hopefully!), the needle will settle all the way to the right and the icon will be white. Hover the mouse of the icon and it should display ‘WAMPSERVER – server Online’. If so, everything is good.
To confirm that the server is running and “serving” web pages, open your web browser and enter http://localhost/ in the address field and press <Enter>. If all is good, you’ll see a web page with the WampServer logo and Server Configuration information. This page will show you the versions of Apache, MySQL, and PHP that are installed, as well as the PHP extensions (more about them later!) loaded. Congratulations! You have a working web server platform running on your machine. Wasn’t very hard, was it?!
If for some reason WampServer is unable to start or, more likely, start completely, see this page for information about troubleshooting problems with WampServer. Keep this page in mind as you make changes to the WampServer configuration. It is almost inevitable that something will go wrong, but that shouldn’t deter you from experimenting and learning from your mistakes. Again, the Apache, MySQL, and PHP communities are very helpful and the Internet is filled with resources on solving these problems.
The web root folder will be, by default, set to c:\wamp\www. The web root folder is like the “home” (base) folder for the local Apache web server. Also, Apache is configured, by default, to “listen” on port 80, which is the standard port for HTTP, the protocol used for web sites. Apache is very flexible and we’ll talk later about how to change some of these common parameters. If you look in the c:\wamp\www folder, you’ll see a file called index.php. When you opened http://localhost/ to test your WampServer installation, the page that was actually displayed (really interpreted for display by the Apache HTTP server) was this index.php file.
But how did Apache know to open index.php specifically? This is just one of Apache’s huge set of configuration parameters (settings). The main Apache configuration file is called httpd.conf. (“httpd” stands for HTTP daemon. The term “daemon” simply means background service and is a term borrowed from Unix. In other words a daemon that runs in the background and performs tasks without user interaction.) You’ll find httpd.conf on WampServer in c:\wamp\bin\apache\Apacheversion\conf, where version is the version number of Apache in your WampServer installation (2.2.11 at the time of this writing). Open httpd.conf with any text editor, such as Notepad. Take a look through httpd.conf to get familiar with its contents. In particular, we are looking for a line that contains DirectoryIndex. When you find it, it will probably contain something like this:
DirectoryIndex index.php index.php3 index.html index.htm
Did you see that this line contains index.php? Remember that we saw that c:\wamp\www folder contained a file named index.php? The DirectoryIndex directive (Apache’s name for commands!) tells Apache what file names to look for if you don’t specify a particular file name when entering a URL (web address) and the order to look for them. Therefore, in this case, Apache looks for a file named index.php first and, if it doesn’t find it, then for index.php3 and so on. Thus, this is how Apache “translated” http://localhost/ to http://localhost/index.php when you tested the WampServer installation.
The other important item from this discussion is that c:\wamp\www in your Windows file system (directory or folder structure) is essentially the same as the “root” folder of the web server provided by WampServer. Thus, if you create another sub-folder in c:\wamp\www, such as c:\wamp\www\mysite, you can access it in your web browser by entering http://localhost/mysite. (Remember that you’ll need to have a file in c:\wamp\www\mysite that Apache can interpret, such as index.html, or you’ll need to specify the specific file to display, such as http://localhost/mysite/myfile.php.)
However, we haven’t explained the localhost part, yet. Basically, localhost is just another name (called an “alias” in the web vernacular) for the loopback IP address of your computer, which is usually 127.0.0.1. This alias is defined, on Windows systems, in the c:\windows\system32\drivers\etc\hosts file. We’ll come back to hosts when we discuss setting up “virtual hosts” (basically multiple web “sites”) in Apache. For now, just remember that c:\wamp\www corresponds to the “root” (top-level) directory of http://localhost/.
That’s it for now. Leave any questions in the comments and look for the next installment in the series soon.