Local WAMP Setup

WAMP is an acronym that derived from the first letter of the following components; Windows (Microsoft’s Operating System), Apache (a web server), MySQL (a RDBMS), and php (a server side script for producing a dynamic web pages). Basically, it’s a combination of software packages to make your Windows machine capable of running as a server; serving web pages with php as the scripting language and MySQL as the database engine. There’s a time that you want to mimic your actual server on your local PC (eg: testing the update that you make on your site) and to do that, assuming you’re using Microsoft Windows, I’ll show you how.

Why I need it?
Let say, for example, you host your own WordPress blog and at some point, there is a new version of WordPress. It’s wise to test whether the new version compatible with your existing plugins and/or theme before you doing an upgrade. Doing it locally will save you from hassle and time wasting.

Before we begin, there are a couple of things I would like to point out:

  1. This guide been made mainly for those that didn’t have any experience setting up a server, but not limited to those group.
  2. This guide can also benefit those who want to shift from using WAMP stack software distribution (eg: Apache2Triad, phptriad, XAMPP) to individual components installation. Just make sure you uninstall your old WAMP first (be mindful to do a backup first!!).
  3. Click the picture to view it in larger resolution.
  4. I don’t have a Vista machine, so I can’t say for sure these steps will work perfectly in Windows Vista. But it shouldn’t have much different though.
  5. It is a guide for newbies, but still, use a common sense when needed. Folder structure and its’ naming convention mostly is my self preferences; if using your own preferences, change accordingly where it’s applied. Eg: If the guide stated that it install in L partition but you install in C, change accordingly where it’s applied.
  6. This guide is only intended for setting up WAMP locally. It’s obviously not enough if you intended to configure your online server without additional steps to the guide.
  7. There is an extra section that point out added information. Check em’ out for common problems, solutions, references, and suggestions.
  8. Questions, comments, & suggestions are always welcomed.

Table of Content (TOC)
This is a section that contains a link to the specific sections.

Preparation (Structure)
I always put all the related components in one place, so it would be easy for me to make any changes later or just for the sake of keeping everything neat.

  1. Start by making a new folder on the intended location (eg: I make a folder called “MyPHP” in my “L” partition).
  2. In that newly created folder, create another new folder called “install” (it will be a place for all your downloaded components).
  3. Create another folder called “root” (it will be a place for your web files & folders).
  4. Create another folder called “Sessions“.

Done with this part; refer to screen shot below. You should have the same structure. (TOC)
The Folder Structure

Preparation (Download)
In this part, we will download all the components and put it inside the “install” folder we created earlier. The components needed are Apache Web Server, php, mysql, and phpMyAdmin.

  1. Download Apache binary at apachelounge.com download section (http://www.apachelounge.com/download/). At the time of writing, the latest version was 2.2.9. (**Notes: Since the Apache binary from ApacheLounge was built with the latest Windows® Platform SDK and Visual Studio C++ 2008 a.k.a VC9, you also need to download & install the Visual C++ 2008 Redistributable Package. Refer the readme that included in the zip files to find out the exact requirement and specifically for this build, you can download the Visual C++ 2008 Redistributable Package from Microsoft.com)
  2. Download php windows binary zip package from php.net. At the time of writing, the latest version was 5.2.6.
    Php download list
  3. Download mysql community server from mysql.com. At the time of writing, the latest version was 5.0.51b.
    MySQL Download List
  4. Download phpmyadmin from phpMyAdmin.net. Choose stable version, not release candidate. At the time of writing, the latest stable version was 2.11.7.

Done with this part; refer to screen shot below. Your “install” folder should be just like in the picture. (TOC)
Install Folder Structure

Installing Apache
In this part, we will go through on the process to install Apache http server. Read more about Apache http server at apache.org.

  1. Extract the httpd-2.2.9-win32-x86-ssl.zip file that had been downloaded earlier.
  2. Read the readme files that come along extracted. Make sure you had fulfilled all the requirement (eg: install Visual C++ 2008 Redistributable Package if you not done it yet)
  3. Rename the extracted folder “Apache2” into “Apache229“.
  4. Move the newly renamed folder into the “MyPHP” folder (just up one level).
    Folder Structure (Apache)
  5. Enter the “Apache229” folder and then to “conf“. Open the “httpd.conf” files with your favorite text editor (eg: you can use notepad).
  6. We are going to do some editing here. Scroll down until you found the following lines and change them accordingly:
    • ServerRoot “c:/Apache2” change it into
      ServerRoot "L:/MyPHP/Apache229"
    • DocumentRoot “c:/Apache2/htdocs” change it into
      DocumentRoot "L:/MyPHP/root"
    • <Directory “c:/Apache2/htdocs”> change it into
      <Directory "L:/MyPHP/root">
  7. Next, open command prompt (shortcut: Run>cmd). Enter the command below to change directory
    cd "L:\MyPHP\Apache229\bin"
  8. Enter the next command to start apache server
    httpd.exe -k start
  9. Click unblock if you get this pop-up.
    Windows Security Alert
  10. Enter the command below to install apache server as service (to make Apache running when the machine start)
    httpd.exe -k install
  11. Now, go back inside “Apache229” folder and then to “bin“. Double click ApacheMonitor.exe and the ApacheMonitor icon will sit next to your clock (green will indicate the server is running, while red indicate otherwise). Make a shortcut of ApacheMonitor and put it into your “startup” folder to make it start automatically everytime you boot your machine.
    Apache Monitor on Taskbar
  12. Put some html files into your “root” folder. Or you can just copy the text below and save it as “index.html
    <title>Test Document</title>
    <b>It works...yehaa</b>
  13. Open your web browser and type localhost (or if your test files use another name like test.html, type http://localhost/test.html instead). If you can see a page load with the phrase “It works…yehaa“, then the installation process is a success. If not, retrace back your step to see if you’re missing anything. (TOC)

Installing PHP
In this part, we will go through on the process to install php. Read more about php at php.net.

  1. Create a folder called “php526” inside the “MyPHP” folder.
  2. Go inside the “install” folder and extract php-5.2.6-Win32.zip into the newly created “php526” folder.
    Php\'s Folder Structure
  3. Now, go inside the “php526” folder and rename the file php.ini-dist to php.ini
  4. Open the “php.ini” with your text editor and get ready for some editing.
    1. doc_root = change it into
      doc_root = "L:\MyPHP\root"
    2. extension_dir = “./” change it into
      extension_dir = "L:\MyPHP\php526\ext"
    3. Scroll down a little bit until you arrive at a section known as “Windows Extensions“. There are a couple of extension list here with the format “extension=name_of_extension.dll” and by default all of them is commented (they have semicolon symbol at the front). So, what you have to do here is uncomment the desired extension by deleting the semicolon symbol to enable them. Now, since we want to run the server with mysql support, the obvious extension that needs to be enable is php_mysql.dll, php_mysqli.dll and php_pdo_mysql.dll (it’s also a good idea to enable php_mbstring.dll and php_gd2.dll since phpmyadmin need it). If the needs to enable other extensions arise later, you can comeback to this section and uncomment them. Do remember to restart Apache to make any changes take effect. (How to restart Apache)
    4. ;session.save_path = “/tmp” change it into
      session.save_path = "L:\MyPHP\Sessions"

      *!!Make sure you don’t forget to delete the semicolon symbol –> ; at the front (to uncomment it)*

  5. Enter the “Apache229” folder and then to “conf“. Open the “httpd.conf” files with your favorite text editor. Do some editing here:
    1. Scroll down until you encounter with the LoadModule section. Add a new line among the LoadModule lines (anywhere; at the end or beginning) as the following:
      LoadModule php5_module "L:/MyPHP/php526/php5apache2_2.dll"

      Example of my LoadModule section (snippets only; more to show where I personally put the line)

      LoadModule isapi_module modules/mod_isapi.so
      LoadModule log_config_module modules/mod_log_config.so
      LoadModule mime_module modules/mod_mime.so
      #LoadModule mime_magic_module modules/mod_mime_magic.so
      LoadModule php5_module "L:/MyPHP/php526/php5apache2_2.dll"
      #LoadModule proxy_module modules/mod_proxy.so
      #LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
    2. Then, scroll down a bit more, find DirectoryIndex index.html line and change it as the following:
      DirectoryIndex index.php index.htm index.html index.html.var
    3. Now, on the same “conf” folder, open file “mime.types” with your text editor. Add the following line into it:
      application/x-httpd-php 	 		php php5
  6. Next, open your System Properties (shortcut: WinFlag + Pause/Break).
  7. Click the Advanced tab and click Environment Variables at lower left side. Go to the System Variables section, find the variable named “Path“, and double click it. Add the following line at the end of line on the Variable value textbox and click OK

    System Properties Screen

  8. Next, click the New button on the System Variable section. Put “PHPRC” as the Variable name and the following line as the Variable value

    Environment Variables Screen

  9. We’re doing all this Environment Variables changes so that we don’t need to contaminate our System32 folder with all the necessary php’s .dll and .ini files.
  10. Restart Apache to make all changes take effect.(How to restart Apache)
  11. Open your favorite text editor, paste the following line and saved it as “phpinfo.php” (or whatever names that you like as long as it have the .php extension) in the “root” folder
  12. Lastly, open your web browser and type “http://localhost/phpinfo.php” in the address bar. It should now show a page that reveal all your php and apache configuration. If it’s not, retrace your step back to see if you’re missing anything. If it still failed to show, as a last resort, you should restart your PC and test it again by opening your web browser. It should work.
    phpinfo Screen shot

Installing MySQL
In this part, we will go through on the process to install MySQL. I must say that this is by far the easiest part of the whole setup process; you shouldn’t encounter much problem since the process is quite straight forward. Read more about MySQL at mysql.com.

  1. Extract the mysql-5.0.51b-win32.zip and run the setup.exe file.
  2. Welcome Screen for the installer; click Next.
    Welcome Screen
  3. Setup Type; choose Custom and click Next.
    MySQL Setup Type Screen
  4. Custom Setup; since I like to group my stuffs in one place, I decided to install MySQL at “L:\MyPHP\MySQL\” (click Change to change the location). Other settings here, leave it at default and click Next.
    MySQL Custom Setup Screen
  5. Ready to Install the Program; click Install and wait until it finish.
  6. MySQL Enterprise; click next 2 times to skip the advert.
    MySQL Enterprise Screen
  7. Wizard Completed; make sure to checked the “Configure the MySQL Server Now” option and click Finish.
    Wizard Completed.
  8. MySQL Server Instance Configuration Wizard; click Next.
    Server Instance Configuration Wizard
  9. Select a configuration type; choose Standard Configuration and click Next.
    MySQL Configuration Type
  10. Set Windows Option; make sure to checked “Install As Windows Service“, “Launch the MySQL Server automatically” and “Include Bin Directory in Windows Path” option. Choose any name from the provided list for the service name and click Next.
    Set Windows Option
  11. Security options; since this is a local setup and for the purpose not to complicated things, I choose to unchecked “Modify Security Settings“. This means that my MySQl Server will have a root user with no password. You can put a password here if you like, just don’t forget em’ later.
    MySQL Modify Security Setting
  12. Ready to execute; click Execute and wait for it to finish.
  13. Processing configuration; press Finish when it’s done.
    MySQL Processing Configuration
  14. Next, open command prompt (shortcut: Run>cmd). Enter the command below to test the MySQL server.
    mysql -u root -p

    Enter the password if you set one and if not, leave it blank and press the enter key.
    MySQL cmd

  15. You should been welcomed to the mysql monitor. Type exit to leave mysql and you’re done on this part. (TOC)

Installing phpMyAdmin
In this part, we will go through on the process to install phpMyAdmin. Read more about phpMyAdmin at phpmyadmin.net.

  1. Extract the phpMyAdmin-2.11.7-english.zip that had been downloaded earlier.
  2. Rename the extracted folder from phpMyAdmin-2.11.7-english to phpMyAdmin-2.11.7
  3. Since I don’t want to mix up my phpMyAdmin folder with the other web files in the “root” folder, I decided to isolate it from there. Move the newly renamed folder (including the content) into the “MyPHP” folder.
    Preparations (pma)
  4. Enter the “Apache229” folder and then to “conf“. Open the “httpd.conf” files with your favorite text editor. We’re going to make some editing here to tell the server where is our phpMyAdmin folder because we didn’t put it in its’ usual place (which is usualy the “root” folder).
    1. Scroll down until you find <IfModule alias_module>
    2. There is a couple of lines after that explaining about the section. Now, after the explanation, but before </IfModule> add the following line
      Alias /mysql/ "L:/MyPHP/phpMyAdmin-2.11.7/"
      <Directory "L:/MyPHP/phpMyAdmin-2.11.7/">
          AllowOverride All
          Order deny,allow
          Deny from all
          Allow from, localhost
    3. Now, if you dislike the alias /mysql/, you can change it to your liking. Just remember it well so you can access it later.
  5. Restart Apache server, open your web browser, and enter “http://localhost/mysql/” on the address bar to start using phpMyAdmin. Don’t forget the trailing forward slash since we declare it has one in the httpd.conf. Just change the mysql/ part if you didn’t use it with yours.
    phpMyAdmin Page
  6. Up to this point, your phpMyAdmin will run with default configuration. If its’ ask for a username or password, it means your MySQL’s user and password.
  7. If you want to make your own configuration file, refer to the phpMyAdmin documentation; the link can be found on the right side of your phpMyAdmin front page (or you can open the file Documentation.html directly located inside your phpMyAdmin folder)
  8. For reference purpose, here is my configuration file. You can copy it and save it as config.inc.php in the phpMyAdmin folder
     * Generated configuration file
     * Generated by: phpMyAdmin setup script by Michal Čihař <michal@cihar.com>
     * Version: $Id: setup.php 10748 2007-10-10 07:30:59Z cybot_tm $
     * Date: Wed, 23 Apr 2008 06:08:22 GMT
    /* Servers configuration */
    $i = 0;
    /* Server localhost (config:root) [1] */
    $cfg['Servers'][$i]['host'] = 'localhost';
    $cfg['Servers'][$i]['extension'] = 'mysql';
    $cfg['Servers'][$i]['connect_type'] = 'tcp';
    $cfg['Servers'][$i]['compress'] = false;
    $cfg['Servers'][$i]['auth_type'] = 'config';
    $cfg['Servers'][$i]['user'] = 'root';
    /* End of servers configuration */
    $cfg['LeftFrameLight'] = true;
    $cfg['LeftFrameDBTree'] = true;
    $cfg['LeftFrameDBSeparator'] = '_';
    $cfg['LeftFrameTableSeparator'] = '__';
    $cfg['LeftFrameTableLevel'] = 1;
    $cfg['LeftDisplayLogo'] = true;
    $cfg['LeftDisplayServers'] = false;
    $cfg['DisplayServersList'] = false;
    $cfg['DisplayDatabasesList'] = false;
    $cfg['LeftPointerEnable'] = true;
    $cfg['DefaultTabServer'] = 'main.php';
    $cfg['DefaultTabDatabase'] = 'db_structure.php';
    $cfg['DefaultTabTable'] = 'tbl_structure.php';
    $cfg['LightTabs'] = false;
    $cfg['ErrorIconic'] = true;
    $cfg['MainPageIconic'] = true;
    $cfg['ReplaceHelpImg'] = true;
    $cfg['NavigationBarIconic'] = 'both';
    $cfg['PropertiesIconic'] = 'both';
    $cfg['BrowsePointerEnable'] = true;
    $cfg['BrowseMarkerEnable'] = true;
    $cfg['ModifyDeleteAtRight'] = false;
    $cfg['ModifyDeleteAtLeft'] = true;
    $cfg['RepeatCells'] = 100;
    $cfg['DefaultDisplay'] = 'horizontal';
    $cfg['GD2Available'] = 'yes';
  9. (TOC)

Now, all things are done. Start placing your web files and folders in the “root” folder. Let say your blog files in the “blog” folder; to access it enter “http://localhost/blog” in your web browser. Don’t panic if there is nothing coming out except for a list of files like the screen shot below. It just mean that at that level you didn’t have one of these files; index.php, index.htm, index.html, or index.html.var (because we set them to be serve first at DirectoryIndex in httpd.conf). If you intent to open a single files directly, type the full address like “http://localhost/blog/wp-admin.php“.
My Root Folder Content Index of

This section contains extra info that related to the installation process.

  • How to restart Apache Server.
    1. There are two ways to restart Apache server; through cmd or Apache Monitor.
    2. Through cmd; open command prompt (shortcut: Run>cmd). Enter the command below to change directory
      cd "L:\MyPHP\Apache229\bin"

      Enter the command below to restart Apache

      httpd.exe -k restart
    3. Through Apache Monitor; right click your Apache Monitor icon on the taskbar, choose open and click restart.
      Apache Monitor Restart I Apache Monitor Restart II
  • There is an alternatives to phpMyAdmin; known as SQLBuddy. Download it, extract and if you put the folder outside of “root” folder, make sure to do the same step as mentioned here. If you put it inside “root” folder, you didn’t have to do anything; no configuration to alter. Open your browser and enter the address “http://localhost/sqlbuddy” (or whatever name that you use).
  • If you feel tired scrolling when editing a config file, use the built-in search function of your text editor (usually the shortcut key is ctrl + F).
  • I suggest when you finish every single phase (installing the component), recheck and make sure it’s running. It’s easier to detect problem if we check it as early as possible. If you already out of idea how to solve things and before you drop me a questions, restart you PC first and retest again.
  • When one of the new components been updated by their developer, before you update your setup, make sure it’s compatible with your other components first. Most of the time, not all the components been updated simultaneously by the developer and that can sometime break things. If you’re sure already, then update your component by revisiting the correspondent steps on this guide.
  • It’s a lie if I said that I come out with all of this purely on my own. Here is example of another guide that I refer:
    1. Installing and configuring Apache on Windows XP
    2. Setup a PHP Development Environment on Windows XP With Apache, PHP 5, MySQL 5, SQLite, Eclipse, Subversion, PHPMyAdmin, and Datapod
    3. Setup WAMP (Windows-Apache-MySQL-PHP)
  • For those who really didn’t have time to configure all this components yourself or just wanna a quick setup (eg: 5 minutes to the class project presentation :-P ), there are an easy way. Using WAMP stack software distribution, most of the time you just need one click install or one time file extraction to install all the necessary components. Among them are:
    1. WampServer
    2. XAMPP
    3. GlossWord WAMP
    4. Apache2Triad

I do hope my post here brings benefit to anyone (including me…I tend to forget things :-P ). One of the main reasons that motivate me to do this post is a constant repetitive emails from some of my friends asking how to setup WAMP on their machine. Well, after this I can point em’ to this post :-P . Again, you guys can help me make this guide better; so any questions or suggestions, drop em’ at the comment box :-D

Tags: , , , , ,