- Internet & the Web»
Install WordPress MU On Localhost 127.0.0.1
Yes you can install WordPress 3.X
Multi Blog / Multi user mode on localhost or 127.0.0.1.
WordPress 3.X Has Built-in Multi Blog Capabilities
I’m not sure whether most non technical people know that from WordPress version 3.X onwards, multi user Blogging capabilities are built directly in the WordPress core itself. This is really exciting because now anyone can use the world’s best Blogging platform and setup up multiple Blogs for themselves OR multiple Blogs that can be access and used by other users and yet be completely independent from each other.
What’s exciting about this one may ask? Well for one there is only a single installation of WordPress setup and configured to run in Multi user mode.
In the past for every additional Blog there had to be:
- A completely fresh installation of WordPress
- With its associated database and tables
- Each such fresh WordPress installation consuming its own amount of hard disk space
- Each associated database and set of tables consuming its own amount of hard disk space
With the release of WordPress version 3.X all this has changed. Since the WordPress core already has multi Blog / Multi User capabilities built in with a little configuration all of the above issues melt away. Now I know a lot of people would like to try installing WordPress in multi Blog mode on their own desktops or laptops first. Play around with this installation for some time to get the hang of using WordPress in multi Blog mode.
While looking around on the Internet, I did not find any tutorials that were clear and lucid, that helped an individual do the following:
- Install and configure WordPress 3.X to work as multi Blog / multi user on localhost
- Then after installation and configuration go on to demonstrate how to Add a new Blogs as well
- All done on your desk top or laptop for try-out / experiment-with purposes on localhost
So I decided that I would write just such a tutorial myself.
NOTE: Most of the tutorials I saw seemed to indicate that it was not possible to install / configure WordPress in Multi Blog mode on a desk top or laptop with Apache web server running identified by localhost or the ip 127.0.0.1.
This believe me is definitely not true.
Sure there is a simple reasons why one cannot install and configure WordPress 3.X to run on localhost or on the ip 127.0.0.1 – but all this requires is some simple entries to be made in your HOSTS file as a work around. The reason being - Domain Name Resolution.
When multiple Blogs are setup, each Blog should be configured to run as a subdomain of the main Blog installation. Now here is where the DNS issue raises its head.
Normally the Main Blog will have its URL which would be something like www.mainblog.com. Assuming one requires another Blog, let’s say firstchild to run as a subdomain its URL will be firstchild.www.mainblog.com which will definitely return a 404 - Page not found error from Apache web server.
WordPress cannot handle a URL that is structured as firstchild.www.mainblog.com , what WordPress can handle is a URL that reads firstchild.mainblog.com ( do notice the absence of www ).
Hence when creating the virtual domain under Apache for the parent Blog ensure that the ServerName directive in the httd-vhosts.conf file is set to mainblog.com and not to www.mainblog.com as is often the case.
Additionally, do remember to ensure the ServerAlias directive in the httd-vhosts.conf file carries the value *. mainblog.com . This informs Apache that there will be multiple aliases used with this specific URL.
Here is what a typical virtual host, set of instructions, to Apache should read like when setting up WordPress to work as a Multi User / Multi Blog in a virtual domain.
# Multi User WordPress Experiments
# Instructions for Apache to locate the multi user WordPress virtual domain - Ivan on 17th Mar 2011
# CustomLog "logs/dummy-host2.localhost-access.log" common
Do pay careful attention to the values assigned to the Apache directives ServerName and ServerAlias .
Domain Name Resolution Issues
The next issue you have to tackle is Domain Name Resolution, which normally requires a Domain Name Server which has the appropriate domain name / ip mapping and offers such resolution to any Browser that requires it.
Well here’s the thing, all Browsers always reference the HOSTS file on the local computer first for domain name resolution before broadcasting the URL on the Internet and waiting for a DNS server to reply with an ip.
Which is just perfect, because you now have a perfect place to do your own domain name resolution on your local desktop or laptop i.e. it’s HOSTS file.
In Windows the HOSTS file is normally found in:
In Linux the HOSTS file is normally found in:
Open the hosts file in your favorite ASCII editor and ensure that it contains the following entries.
127.0.0.1 localhost localhost.localdomain
If your hosts file contains the entry:
Simply copy / paste this entry in your hosts file, so that you have duplicate entries.
Then place a # sign in front of the second line, ( i.e. the one you just copy / pasted ) to rem it out.
Next delete the .localdomain section from the current entry that is not remmed out.
Your host file entries should look like this:
( Notice the .localdomain section is deleted )
NOTE: The separator between the ip and the URL being a TAB.
The next few entries you will have to make are going to the be the URLs of your main Blog and its associated child Blogs so that when you are testing your installation your Browser will get its URL to ip resolved from within your hosts file.
If not all you will get is a 404 page not found error from Apache when you try to connect to your Main or Child Blogs.
Here is what a typical hosts file entry would look like if you had a main Blog whose URL was multiuserwp.com with two child Blogs one named meher.multiuserwp.com and the other named parab.multiuserwp.com
All you have to do to when you want to add another Blog in your local Apache installation is add yet another line in your hosts file with the appropriate URL.
This approach will really take care of all the DNS resolution that you might need when testing WordPress out in multi Blog / multi user mode on your local computer.
If you would like to read about how you should install and configure WordPress 3.x in Multi Blog / Multi User mode I’m writing a tutorial on that pretty soon. Do watch this space.