WAMP: easier than you think
By Luke Labern
The PHP language, an apache server and a MySQL database are most welcome to any would-be programmer. And, if they cannot or do not wish to use a Linux environment, and want to use Windows, it is quite complicated to set up. At least, the majority of those who want to learn PHP have learnt HTML, maybe a bit of CSS (or may have been referred from PERL) and are new-ish.
The set-up, commonly known as “WAMP�; Windows: Apache: MySQL: PHP (sometimes PERL is the language instead of PHP but that is not important) go hand in hand. Although, Linux is probably a better OS for all of this, a lot of people do not want the hassle of setting it all up, even though it is relatively easy. Some people are just plain scared of shell code. Whatever.
Aside from Windows, the other three components are as free as oxygen: open source. I assume, from hereon, that you know what all three things you’re going to be installing actually are.
First of all, I will link you to the relevant places. With this article, instead of confusing you about where to save everything, I will give you the link to the correct webpage as we need it. First up: Apache.
NOTE: I will be writing this with these version used (the most current at the time of writing):
Apache 2.0.55
MySQL 4.1
PHP 5.0.5
When you follow this tutorial, I expect all installed files (as their default) to go to C:\program files, so make sure that they actually go to their default place (unless you use this more as a reference).
APACHE WEBSERVERDownload and install
http://httpd.apache.org/download.cgiFirst of all, create a new folder on your desktop named “WAMP� where you can temporarily download all the installers to.
Go to the link above and download the Win32 Binary (MSI Installer).
When the download finishes run the installer and when prompted enter “localhost� as your server (minus the quotation marks) and your e-mail address, though it doesn’t really matter what e-mail address you put in.
Test the serverOpen up a web browser (I suggest firefox, of course) and enter “localhost� or “http://localhost� into the address bar. When the page loads you should see a page congratulating you; you just correctly installed Apache!
Of course, you’ll probably just want to test it out some more, so providing you installed it to the default (which I told you to), find the folder: C:\Program Files\Apache Group\Apache 2\htdocs and insert an html document there.
If you want a new page to automatically load from ‘locahost’ instead of the default, add a new index.html file in ‘htdocs’ and choose “yes� when it asks you to replace the old one. For other files placed in htdocs, add a forward slash (/) and the file name with extention after ‘locahost’
E.g: for a file named “websitename.html� that is saved in ‘htdocs’, type: “http://localhost/websitename.html� into your address bar.
Next, it’s onto the databse, courtesy of MySQL.
MySQL DATABASEDownload and install
http://dev.mysql.com/downloads/mysql/4.1.htmlThe link above is the official place to download the packadge, but be warned: it’s pretty much intended at Linux users and you have to navigate your way down to the windows section (in Firefox, hold ctrl+f and type in “windows downloads� to get there faster) and download the Windows (x86). It’s bigger, but instead of the ‘essentials’ version there’s less chance of a file going missing.
Download to the temp folder on your desktop and run ‘setup.exe’. Follow the simple onscreen instructions and then, perhaps, it will have installed itself. What do I mean? Well, sometimes (depending on what you downloaded) there will be an additional set of windows to navigate through which will let you set a password and customise your database. You can skip this, but you will be faced with some conolse instructions if you do not want this graphical interface.
I suggest you use the new, easier options and of course to set a password, but if you’re more “hardcore� then by all means go ahead and do the following:
Click Star -> Run and type ‘cmd’ into the box and press ‘ok’. In the new console window type in (and hopefully receive) the following:
Enter: cd c:\mysql\bin
Enter: mysqld-max-nt --install
Response: Service successfully installed.
Enter: net start MySql
Console should say: The MySql service is starting.
Console should say: The MySql service was started successfully.
Well done; from either of the two different ways, you have installed MySQL!
But if you used the console window to set up the database you should still set a password by doing the following in a console window:
Enter: cd c:\mysql\bin
Enter: mysql -u root mysql
Response: Welcome to the MySQL monitor .....
Enter: UPDATE user SET Password=PASSWORD('new_password')
Enter: WHERE user='root';
Response: OK...
Enter: FLUSH PRIVILEGES;
Response: OK...
Enter: DELETE FROM user WHERE user='';
Response: OK...
Enter: DELETE FROM user WHERE Host='%';
Response: OK...
Enter: DELETE FROM user WHERE User='';
Response: OK...
Enter: DELETE FROM db WHERE Host='%';
Response: OK...
Enter: exit
And the console window will close.
Now it’s time for the PHP installation, which I think is the hardest by far. But I will make it as simple as possible.
PHPCreate a PHP folder
This step is very important; without this the PHP installation will not work. On your local disk directory “C:�, create the folder “PHP�. Download the zip package and extract the files into the C:\PHP folder.
Download and installhttp://www.php.net/downloads.phpUnder “Windows Binaries�, choose “PHP 5.0.5 zip package� (if that’s what you want, but I it is very important that, if you are following this tutorial you do) and download that to your temp directory.
When you unzip it, make sure it is unzipped to C:\PHP (see above).
Now, this is probably the most confusing part.
Select the following files (they may be named differently, but using your brain you should be able to workout which) and copy them into your C:\Program Files\Apache Group\Apache 2 folder.
C:\php\php5ts.dll
C:\php\sapi\php5apache2.dll
C:\php\php.ini-recommended
Rename ‘php.ini-reccomended’ (the one inside the Apache 2 folder) to ‘php.ini’ and open it in Notepad. Search for ‘doc_root’ until you find the line :
doc_root =
Change this line to:
doc_root = C:\Program Files\Apache Group\Apache 2\htdocs
Save and next navigate to C:\Program Files\Apache Group\Apache2\conf\ and find the file ‘httpd.conf’ and open it in Notepad.
Add the following lines to the bottom of the text:
LoadModule php5_module php5apache2.dll
AddType application/x-httpd-php .php
Save it.
Guess what? You just did it! PHP is installed. In fact, WAMP is installed!
Test PHPTo test that it actually has been correctly installed, click Start -> All Programs -> Apache -> Configuration -> Test configuration.
A console window should appear for a little less than a second then close itself. If this happens, everything is done! If not, take note of any errors displayed and refer to the instructions above.
For Apache to recognise PHP, Apache must be restarted. Click Start -> All Programs -> Apache -> Control -> Restart.
Now for the classic test of whether PHP and Apache are working together.
Create a new .txt document, preferably in Notepad.
Type in the following:
echo ‘If you can see the information below, PHP is correctly installed.’;
phpinfo();
?>
(note that anyone with a bit of php knowledge already will know that the semi-colon after the ‘phpinfo()’ line isn’t necessary, but just add it to be sure at this stage)
Save that as ‘phpinfo.php’ in the root doc folder, which is “C:\Program Files\Apache Group\Apache 2\htdocs�.
Open up a web browser and navigate to “http://localhost/phpinfo.php�.
If, when you reach the page, there is text saying “If you can see the information below, PHP is correctly installed.� And there is a long page of text in purple tables, then the text is right: we’re done!
Further readingThere are a lot of brilliant php tutorials and books around, but for a full-blown official documentation, visit php.net’s official master document!
http://www.php.net/manual/en/Now, go learn PHP!
© Luke Labern Oct/05.