Setting Up a WAMP Environment
I thought about it and one thing I have not yet done is a little tutorial on how to set up a WAMP environment for testing out websites. I believe that every web designer or web developer should have some sort of test bed that they can use without having to upload their scripts all the time.
Now in this little tutorial I don’t plan on showing you how to set up MySQL which is the M in WAMP but I will mention the rest.
For those who don’t know what a WAMP server is, the acronym stands for: Windows, Apache, MySQL, PHP. It’s just that simple!
What do I need to run a WAMP server? Just remember, I’m skipping MySQL at this point because I tend to use a MySQL database that has already been set up on a live server.
- Windows should be running on your machine
- Apache - The windows install file can be found on Apache’s HTTPD server site: Win32 Binary (MSI Installer) [4.3 MB]
- MySQL - You can download their windows install file and run that, but this tutorial won’t include it
- PHP - PHP’s windows installer can also be grabbed from their site: Windows Binaries 5.2.2 installer [21.5 MB]
The windows installers for the above programs just make it easier for the novice to get all the servers running in harmony without much difficulty.
Installation:
Apache: When you start the installer for Apache you will be prompt by various settings, I would primarily stick to the default settings except for when they ask for the domain name and email address for the administrator. Here you can see I use localhost for the Network Name, and Server Name and I use admin@localhost as the administrator’s email. Using localhost will ensure that the server will properly read the documents without any issues from your computer.
If you plan on using PHP’s Windows installer be sure to leave the default installation directory for Apache as well, this will just make setting up PHP and Apache easier for you.
After Apache has been installed it should start the Apache Monitor, I would normally stop the Apache Monitor prior to setting up PHP just to make sure here are no files being used that the PHP installer might need to write to if Apache is using them.
PHP: I’ve chosen to install the latest stable build of PHP which is 5.2.2. This will ensure that I have all the latest and greatest functions and methods that PHP has to offer.
Now when you first install PHP you will be asked where to install it, I’ve always installed it at the root of the C drive, that way it is a bit easier to find the install directory if you ever needing to change things like the php.ini file. So for the install directory use c:\PHP
Next you will be asked as to how you wish to use PHP with the Apache server. For the purposes of this tutorial as well as the version of Apache we are running (2.2) select the Apache 2.2.x Module.
Now remember how I said to have Apache use the default location for its installation? This next step for installing PHP will now ask you for where Apache is installed. You will have to browse to it but the screenshot also shows you the default location in case you forgot.
Now on to the more important step, that is, what extensions you wish to run with your PHP installation. The following are the extensions I like to run and I believe should be the minimum. If you need to add or remove an extension you will need to run the PHP installation and choose the Change/Modify option and add/remove what you need.
clibPDF – Lets you create PDF Documents
CURL – Client URL library functions
EXIF - EXIF functions
GD2 – This is the GD2 library for creating images on the fly with PHP
Imagick – Another graphic library similar to the GD2
MySQL – Even though this tutorial doesn’t have a MySQL installation section, I will still add this so that I can do MySQL Functions with PHP via a remote database
PDFlib – Another library for creating PDF documents on the fly
SMTP – Simple Mail Transfer Protocol, want to be able to send email via your test environment?
SOAP – Because some scripts require it, though I have not had to use SOAP it’s nice to make sure it is installed
Sockets – You never know when you might need to make socket calls with PHP
That would be it for the extensions that I would install, again you might not need all of them, or you might need more. Take a look at what it is you need to do for your projects and adjust. I’ve had situations on my Linux development environment where I haven’t had an extension installed and I had to recompile PHP in order to continue my work.
Next I would look at the Extras and would install PEAR. PEAR can be quite useful and some scripts require it. Of course I have not yet done any programming with PEAR but it is up to you whether or not to install it. Some people also might install the PHP Manual; this can be helpful when needing to look up what a particular function does.
The PHP installation should go without any issues and you should almost be ready to play with your development environment. The next step is to configure Apache a little bit to make it a little easier to work with in regards to finding files.
httpd.conf (Apache Settings): The httpd.conf file is easily accessible via your Start Menu. Start -> All Programs-> Apache -> Configure Server -> httpd.conf (or something to that effect). The httpd.conf file is the settings file for your Apache server. Luckily with a WAMP installation there isn’t much to change to get it to work nicely.
ServerRoot “C:/Apache2” - If this is what it says you’ll need to change it to the path of where your Apache installation is like this:
ServerRoot "C:/Program Files/Apache Software Foundation/Apache2.2"
The next one I always change is the DocumentRoot. The DocumentRoot is where you base website files go. For me it’s easier to work from the My Documents folder under a generic www folder. To do this you would simple find the line:
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
And change it to:
DocumentRoot "C:/Documents and Settings/Tyler/My Documents/www"
Ensuring that you have created the www folder and you change the name accordingly. You will also need to find the Directory Directive. This is easy because should be a few lines down from the DocumentRoot and says ‘This should be changed to whatever you set DocumentRoot to’
<Directory "C:/Documents and Settings/Tyler/My Documents/www">
Last but not least is to change the Directory Index if it has not been done so by the PHP installation. Look for a line that says
DirectoryIndex index.html
And add index.php to the end of it, that way if you make index.php files and not index.html files Apache will read them without any issues.
The next thing I like to make sure is that Apache will parse .html files for PHP scripting. This is done by adding the following line to the bottom of the httpd.conf file:
AddType application/x-httpd-php .php .html
You should be all ready to go! Just start up Apache via the Apache Monitor, open your favorite browser (like Firefox) and type in http://localhost and it should be good to go. It might display a blank page because there is nothing in your DocumentRoot so I like to add this little script to make sure a) Apache is running and b) PHP is configured and running:
Create a new document and call it phpinfo.php.
Inside that file type these lines
[code]
<?php
phpinfo();
?>
[/code]
Save the file and point your favorite browser (like Firefox) to http://localhost/phpinfo.php if everything is set up properly you should see the configuration of your PHP set up in a nice table.
Hopefully this tutorial for setting up a WAMP (without the M) environment on your Windows machines has been useful and informative and everything goes smooth for you. I believe it is a great asset to web developers and designers to have a place where they can test their scripts/projects without having to upload it to a live web server. Also on a laptop it is nice to be able to show clients their websites without needing an internet connection too in case one is not available.






Tyler you are a goawd send. You wouldn’t believe what I’ve been trying to do for the last week. I’ve been trying unsuccessfully to set up a WAMP environment. This is so funny that you publish a tutorial just days later. Did my wife call you or something????????
Brennan the Grateful Vyper
Hehe naw she didn’t call. I was just setting up this here laptop and thought about how less difficult it can be to set up a WAMP install than an LAMP install.
Let me know how your set up goes!
Worked like a charm thanks a bundle.
Brennan the Vyper
No problem! Glad I could be of help!