Paul Jardine Web Design

Freelance Web Designer & Developer from Stockport


Local development environments are a cornerstone to any web developer’s toolkit (unless you like endlessly uploading files via FTP whenever you want to check a small CSS update).

If you’re building a site using PHP and running a Windows machine, WAMP Server in an invaluable tool for running a local development environment off your laptop (Mac users should check out MAMP).

In it’s default setup, WAMP will run whatever website you have sitting in your c:/wamp/www folder when you go to http://localhost in your browser.

If you’re working on multiple projects it’s much more organised to separate each one into it’s own individual development environment with it’s own testing domain and folder structure which you can easily hook up to an independent version control repo.

In this tutorial we’ll create a new local dev site to run from http://project1/

Step 1 – Create your project root folder

First, you need to create your folder to run your project from.

Go to the folder c:/wamp/www and create a new folder called project1.

Step 2 – Set up your Virtual Host

  1. Go to C:\wamp\bin\apache\ apache2.4.9\conf\extra (note that the apache2.4.9 might be different on your setup depending what version you have installed on your machine. Just remember that the Apache folder is the one you need to go in!)
  2. Open httpd-vhosts.conf
  3. Look for the default settings for localhost
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/"
ServerName localhost
ServerAlias www.localhost
  1. Copy this and paste it below the default settings and replace all your references to localhost with project1. Also make sure the DocumentRoot value points to your new folder you just created like so…
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/project1/"
ServerName project1
ServerAlias www. project1

Step 3 – Update your hosts file

Next you need to set your local DNS so your URL points to your new folder on your local server.

  1. Right click on the Notepad app icon and select more > run as administrator. If you are not running as an admin you won’t be able to save your updates.
  2. Go file > open and navigate to C:\Windows\System32\ drivers\etc
  3. This will likely show up an empty folder because the dialogie box will only lists text files by default. In the bottom right corner of the [box] change the Text Documents (*.txt) value in the dropdown box to All Files (*.*)

  1. Open your hosts file
  2. You’ll see the line       localhost
  3. Copy this and paste it on a new line and as before simply replace localhost with project1.
  4. Save the file and close it.

The updated file should look like this… localhost project1

Step 4 – Create a new database

If you don’t need a database skip straight to step 5.

  1. Activate WAMP server if it’s not already running.
  2. Click on the WAMP toolbar icon in the bottom right of your screen and then select phpMyAdmin
  3. The left column of phpMyAdmin lists all your existing databases. At the top of this list, click on New.
  4. In the Create Database field, give your database a name and hit create.

This will create your empty database.

Step 5 – Restart all services

  1. Activate WAMP server if it’s not already running
  2. Click on the WAMP toolbar icon (if the server is running correctly it should be green) and click on Restart All Services.
  3. The icon will turn to red, then orange and the green again.

That’s it! Go to http://project1/ and your local dev site should be up and running. Simply stick your website files in the project1 folder you created earlier and your development server will be visible at the URL you chose.

Note that if you’ve already looked at http://project1 before updating your hosts file you may get an error as your old DNS may still be cached in your browser. In this case you’ll need to flush your DNS on your machine. Close your browser, open your command prompt app and then type

ipconfig /flushdns

Alternatively, sometimes simply clearing your browser cache (ctrl+F5) can do the trick too.

Note for WordPress

If you’re setting up a local WordPress website, unless you’ve already configured phpMyAdmin the default username is root and the password box should be left empty. The database host can be left as localhost.

Posted in Tutorials | Tagged ,

About Paul Jardine

Paul Jardine - Web Designer Stockport

I am a freelance website designer and developer building websites for the good people of Stockport, Manchester and beyond!

I offer web design and bespoke WordPress development services to private clients, digital agencies and local charities.

Please feel free to take a look at some of my work and if you are interested in working together, or simply fancy a chat about what I do, please get in touch.

Get in touch today!
Say hello!