Set up a local server with wordpress

In my last post on WordPress we looked at using it as a viable option for non-blogging web sites (i.e. a full CMS), some of the benefits and alternatives. If you're convinced that WordPress is the right platform for you then read on...

In this post, using, I'll be running you through all the steps you need to get you set up with a local server environment running with a copy of WordPress so you can play about with the code without worrying about who's looking at it or breaking it. and - What's the difference?

Before we go any further, let's get one thing straight - what's the difference between and is straight up for quick WordPress installations, hosted by WordPress themselves. This is great for non-developers who simply want a blog with the default features and don't want to pay for, or get involved in managing the hosting side of things. The downside of this type of WordPress installation though is that you cannot modify the code, and the themes and plugins you can use are limited. on the other hand is where the developers get involved. The WordPress 'platform' can be downloaded as a software package to install and build on. This site features all the documentation, themes and plugins that you can customise on an installation of WordPress that you would host yourself. 

What's a 'local' environment and why do I need one?

One last thing before we dive in then, what's a local environment? A local environment is the concept of turning your personal computer (i.e. local) into a server so that it can behave in a way that your web hosting server would. This allows you to setup your own local domains and web sites so that you can test your code before you put it into a live environment. What does this mean practically? You can have with a copy of your code for building on and testing, and then when it's ready you can upload the site to so that everyone can see it. If you need to make any future changes to the site, you can test them on before you push them up to live. 

If you're only interested in the steps to setup WordPress then feel free to jump ahead.

Without further ado...

Setup a local server

So first we need to configure your computer as a server. Throughout this tutorial I will be giving steps predominantly orientated towards PC users, but I'll try to provide additional resources for mac users where possible. 

There's two leading pieces of software for setting up local server environments, these are XAMPP and WAMP (MAMP for Mac users). These will both allow you to run PHP and MySQL on your computer. 

Honestly, there is very little difference between WAMP and XAMPP, I use one at work and the other on my home machines and both achieve the same results. Generally I believe WAMPSERVER to by more widely used and user-friendly so I'd recommend this choice if you're unsure. Have a read up if you want to, choose an option and download their software, default configuration options are fine. 

Set up a local domain

So now you've got a local server, you'll need a local domain that you'll be accessing WordPress on. For my local environments I always use '.dev' so I know I'm working locally, you don't want to be using '' or '.com' like the live versions otherwise it would always override the real version. Follow these steps to setup '' locally (though you can call this whatever suits you best):

  • In your start menu search bar type notepad, right click the application and click 'Run as administrator'. 
  • In notepad, go to 'File' > 'Open', browse to C:\Windows\System32\drivers\etc, select 'All files' and open the 'hosts' file
  • Copy a new line that reads:
  • Save and close the file
  • Next you want to find your httpd.conf file, if you've gone for a WAMP installation you can click on the green WAMP option in your menu bar, go to 'Apache' > 'httpd.conf'. Alternatively for XAMPP you can use the vhosts conf file located here by default: C:\xampp\apache\conf\extra\httpd.vhosts.conf
  • In either of those files (for httpd.conf add it after 'ServerName localhost'), add the following code block for a new domain:

    <VirtualHost *:80>
    DocumentRoot "C:\xampp\htdocs\wordpress\public"
    ErrorLog "logs\wordpress.log"

    Change the document root to the path to where you want to store your site files. For WAMP I would recommend 'C:\wamp\www\wordpress\public'
  • Lastly, click on your XAMPP or WAMP icon in your tool bar and restart the services to refresh the settings. 

To test your configuration is working, create the folder 'wordpress' inside 'htdocs' or 'www', create another folder inside this called 'public',  and finally place an index.html file in your public directory for the site (with a 'hello world' in it). Browse to in your browser and you should see this appear. 

Congratulations, you've set up a local server!

Setup a database

WordPress does most of the default database configuration for you, but you will at least need to set the actual database up first. Follow these steps:

  • Browse to http://localhost/phpmyadmin/ to view phpMyAdmin (for WAMP you can right click your icon and this will be a menu option)
  • Click on the 'Databases' tab, and in the 'Create new database' field type in 'wordpress' and click 'Create'

Well that was easy.

Install WordPress

Download and extract the files

Next we need a copy of WordPress, you can download this from

Extract the downloaded files into your public folder we created earlier.

Edit the wp-config.php file

Inside the public folder you will now find a file called wp-config.php, this contains all the core site settings. Open it up and update the following settings for the database you set up earlier, if you're using the root user then you should only need to change the DB_NAME for now (note this would be different for a live environment as you would never use the 'root' user in production):

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');

/** MySQL database username */
define('DB_USER', 'root');

/** MySQL database password */
define('DB_PASSWORD', '');

/** MySQL hostname */
define('DB_HOST', 'localhost');

Finally, go to in your browser and follow the default installation steps to complete the setup process.

For more configuration options check out the WordPress codex installation guide.

Get your hands dirty

Now you've got your own local copy of WordPress up and running you can go ahead and play with the code as much as you want without worrying about breaking anything. In upcoming posts we'll be looking at the core WordPress concepts and how to create your own 'child' theme based off the default 'TwentyThirteen'.


Sign Up
comments powered by Disqus

Popular Tags

Need a web developer?

If you'd like to work with code synthesis on your next project get in touch via the contact page.