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:WindowsSystem32driversetchosts`
    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!

Team Web Hosting

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. Great guide Neil. Can’t wait to try it.

  2. Salem says:

    You Answer what exactly what I looking for .. I have PC Software Review Site and I was Looking To add Mobile Section as Sub Dmain
    My website on paid web hosting and wonder if I have Do the all step from “custom WordPress multisite install address ” Or I start from “Installing WordPress Multi-Site” << any way I will try that first .
    Thanks again .

  3. Bayu Idham Fathurachman says:

    you rock !!!!
    thanks man , this post is really helpful :)

  4. gof says:

    This is great… I ‘m just setting up wordpress multisite with subdomain in my local host. And your tutorial works for mine.

  5. BlueAngel says:

    I’m trying to set up wordpress v3.51 multisite in my xampp localhost. My goal is to setup as Sub-domain instead of sub-directory so I can have many sites running in my development server on a single installation.

    However, when I clicked the ‘Network Setup’ tag (under the Tools tag of Admin
    login), only the sub-directory option showed, no Sub-domain option though.

    Below are the steps that I followed –

    Step 1 . Adding following line to hosts file: wp351

    Step 2. Adding following code to httpd-vhosts.conf file:

    NameVirtualHost *:80

    DocumentRoot “C:/xampp/htdocs”
    ServerName localhost

    DocumentRoot “C:/xampp/htdocs/wp351”
    ServerAlias *

    AllowOverride All
    Options Indexes FollowSymLinks
    Order allow,deny
    Allow from all

    Step 3. Flushed DNS and restarted Apache.

    Step 4. Created database using phpMyAdmin

    Step 5. Downloaded WordPress 3.51 and Installed it into C:/xampp/hdocs/wp351, completed the setup.

    Step 6. Enabled the multisite network – added following line to web-config.php above the line /* That’s all, stop editing …*/
    define(‘WP_ALLOW_MULTISITE’, true);

    Step 7. Logged in to “localhost/wp351/wp-admin” , at Tools | Networks Settings, all I get is sub-directory shown in the above screen shot.

    I checked the added code listed above in letter, but don’t see anything wrong with it.
    I’ve tried clear the cache, flush DNS records, re-start Apache and mySql, no help.
    Already removed the database and wordpress 3.51, and start from scratch, still get the same results. I’m stuck now!

    What did I do wrong in the above steps? Or is there something I missed out?


    • Neil Sweeney says:

      Hmm not too sure. I know if you have a site setup already then you are only allowed to do sub-domain installs, which isn’t your issue.

      Make sure that there are no plugins enabled before you do the multi-site setup and that if you have a .htaccess file, delete it for now as that can cause issues.

      I’ve just done a quick test on my Mac (I’m not using XAMPP though but OS X’s native Apache setup) with WP 3.5.1 and I was given the option to do sub-domains and folders.

    • Max says:

      i know this is an old post but … i use xampp on W7 and now i setup a wp MU sub domain.

      Try to add following on hosts files: *

      last line is a wildcard for ALL local subdomain