One of the often missed features of WordPress is the ability to run more than one site off it. It’s thought that WordPress can be a bit bloated at time with the number of database connections it does, but so long as you keep those connections under control with page caching, then WordPress can have many sites running from a single install; this is exactly how (a network of hosted WordPress blogs) works.

There are a number of blogs out there that will explain to you how to install a WordPress Multi-Site on your localhost, but they’ll use the sub-folder method, which is fine but I like working from the root. So I’ll try to explain why I use a multi-site install, how you can use it and will explain how to get it working on your localhost with sub-domains.

Why Have a Multi-Site Install

One strong advantaged of working with a WordPress Multisite install is versioning of WordPress’. Although I’ve not tested this to see if it would be any good or if it would work across every recent versions but for those hardcore developers who wish to test with regards to versions, this maybe a good idea.

Any who, it’s handy to have a single WordPress install base rather than having the same files a number of times that you don’t really care about. When I was looking up last night on how to setup a local install with subdomains (such as there was no real documentation how to do it, it was all sub-directories (such as This doesn’t really suite me as I work with sites from the root rather than the directory so I was desperate to find out how to do this, lucky for those reading this I did.

Setting Up the Host

This can be a little tricky and change depending on your (L/M/W)AMP stack and operating system, so I will try to cover the best I can with all three stacks; Linux, Mac and Windows.

  1. Find your system host file and add your custom WordPress Multisite install address (mine is mu.wp) by adding the line: mu.wp

    Windows `C:\Windows\System32\drivers\etc\hosts`
    Make sure you can view hidden files and have admin privileges.
    Mac `/private/etc/hosts`
    Use this tutorial for further instructions.
    Linux `/etc/hosts`
    Use this tutorial for further instructions.

  2. You might also want to add any sub-domains now to your host file as you will manually need to add each one; for now I just want to add, which is as simple as adding a space and typing in the URL next to your install address so you should have a line that now looks like this: mu.wp

    Whenever you want to add another sub-domain, just add it to the same line.

  3. Find your Apache `httpd-vhosts.conf` file; head towards your Apache install folder and follow the path `conf/extra/httpd-vhosts.conf` (Windows requires admin privileges). Keep in mind; this might not be correct and if so, do a system file search for the file, or if you can’t find it then go to `conf/httpd.conf` (requires admin privileges)
  4. Check that the line NameVirtualHost *:80 is included in that file, if not then add it.
  5. Now add the the follow block of code (taking into account that some parts will need changing:
    <virtualhost *:80>
    	ServerName mu.wp
    	ServerAlias *.mu.wp
    		AllowOverride All
    		Options Indexes FollowSymLinks
    		Order allow,deny
    		Allow from all

    To clarify a few parts, `ServerName mu.wp` is the same as our host file name and `ServerAlias *.mu.wp` is the same again but we added `*`. as a prefix that acts as a wildcard, so anything will be accepted as a sub-domain pre-say

  6. Now flush your DNS records and restart Apache (may not work for all installs of Apache, if that’s the case then you will have to look for the relevant documentation) and you can continue with the standard WordPress install

Installing WordPress Multisite

  1. Install WordPress as normal keeping in mind the options you choose now will be used on that root domain (so mine is called MU with the address http://mu.wp/)
  2. Once installed and working, head to your `wp-config.php` file and add the line define('WP_ALLOW_MULTISITE', true); above the line /* That's all, stop editing! Happy blogging. */
  3. Go into your WordPress admin area hover over the menu item “Tools” and look for the option “Network Setup” and click on it.Network Setup option for WordPress multi-site install
  4. In the “Create a Network” page you want to select the “sub-domain” option and then click the “Install” button.Choose the `Sub-domains` option
  5. You’re now presented with three things to do before your network is fully operational
    1. Create the blog.dir folder in the wp-content folder (that can be seen in the root).
    2. Copy the contents of the first textarea and add it to the wp-config.php we previously edited.
    3. Copy the contents of the second textarea and add it to the .htaccess file in the root of your WordPress install. Keep in-mind that file beginning with a . are seen as system files and thus are invisible so you may have to make it visible (here’s how to for various systems: Mac, Windows 7 and Vista, Linux). If you still can’t see it then you just need to create the file.
  6. Log out and back into your WordPress admin area and you should see a new option under the “Dashboard” menu item, namely “My Sites”, this lists all the sites you have currently available to you in your network. Ignore that option for now and hover just above that to the “My Sites” in the admin bar, hover over “Network Admin” and click on “Sites”.

    Network admin menu

  7. You are now in a page with a similar style to the post/page view; here you can add a site, so click “Add Site” towards the top and fill in the relevant details (mine was for You should be now able to access that new sub-domain.

That should be it; all you need to remember to do is add each new sub-domain you want to the `host` file. There are easier ways of doing, I for one use MAMP Pro on my Mac that handles all the Apache and `host` file configurations in a nice GUI. Not sure on Windows and Linux options that allow you to manage Apache using a pretty GUI, if you do though please share with us!

Neil Sweeney Web Developer

Neil was a front-end developer working on Fubra World projects. He does a bit of gaming, music, photography, snowboarding & rodent taming.