Tuesday, September 20, 2011

Multi-Site in WordPress

SkyHi @ Tuesday, September 20, 2011
Wordpress is my favorite website platform .One of the really cool features that WordPress offers is Multi-sites. Mult-sites can be turned on in any recent WordPress installation (3.0 and up).Turning on multi-sites allows you to create and manage as many sites as you want from a single WordPress installation. It is not difficult to activate multi-sites and there are tons of blogs out there that will walk you through the process (like this one), but if you want to use different domains on each of your new sites, you will need to either install a plugin ( I have never used this method) or you can use the little trick I am going to write about.

This trick will let you use a different domain for each new website you create in your WordPress installation. So for example, you have your WordPress installed on jacksblog.net, and have set up multi-sites. You create a new site called jacksblog.net/bobsblog, but you really want to use your other domain “bobsblog.net.” No problem! You are at the right place. This trick will make that happen, and will work for as many new sites as you care to create (as long as you have a domain for each new site).

/*TECH NOTE*/
This method involves going into  your MySQL database and creating a new record by hand, and modifying another record. If you are not comfortable with doing this, then better to use a plugin. Also, make sure you have backed up your database and website files in case something goes crazy-ape bonkers.

Using Different Domains on WordPress Multi-sites

So you have multi-sites turned on, and you have another domain you would like to use on a new site you will create. There are a few steps you need to do (the following has worked for me using BlueHost and DreamHost, but should work with other domains as well) :
  • Set your new domain to be Parked (BlueHost) or Mirrored to your original domain (DreamHost)
  • Create a new site in your WordPress install. Just using a sub-domain for now.
  • Go into the MySQL database your WordPress is using, and add a new record in the sites table.

Ready? Here we go. For this setup, I have installed WordPress on my brother-in-laws domain space “3fc.co“, and set up a website for him. I wanted to create an additional site on the same WordPress install for my father-in-law’s website using the domain “filleywood.com“. That way I could manage both websites from a single location.

Firstly, I activated “Multi-Sites” using the basic instructions you can find on your blog of choice. Then I logged in as Network Admin and created a new site called 3fc.co/filleywood

Next, I needed to point the domain filleywood.com to  3fc.co. In DreamHost, this is done by setting filleywood.com to mirror 3fc.co (which is set as “Fully Hosted”.)  In BlueHost, you have one domain that is your primary domain, and then you just “Park” your new domains. whatever your hosting company, the goal is to make your new domain point to wherever you have WordPress installed..WordPress will take care of the rest.

It should be noted that once you change settings for a domain with your hosting company, it can take a few hours or more for those changes to take effect, so make sure to wait a while before freaking out.

So I have my second site set up and I have my second domain pointing to my WordPress install. Now I need to makes some changes to the MySQL database that WordPress is using. I will use phpMyadmin for this, but you could use MySQL Workbench or even PuTTy if you want.
  • Log in to phpMysql and choose the database WordPress is using.
  • From the list of tables on the left, choose wp_sites
  • Click the Insert tab to insert a new record
  • Type in 2 in the ID field (or higher number, depending on how many times you have done this..second site gets 2, 3rd site gets 3…)
  • Type in the domain you want to use for your new site in the Domain field
  • Type in / for path
  • Click the Go button to add this record, now you should see the new site in the list of sites

  • Now click on the wp-blogs table on the left
  • Click the pencil icon next to the blog(site) that will get the new domain
  • Change the domain field to your new domain (fillywood.com) and change the path to /
  • Click the GO button to save changes, you should see your changes saved in the list

  • You can leave phpMyadmin, and log into your WordPress site as Network Admin, and go to Network admin (upper-right hand corner drop-down)
  • Go to Sites
  • Choose “edit” on the site that has the new domain name..it can be hard to tell which is which now because they all have the same path /
  • On the “Settings” tab, check the SiteURL, Home, and FileUploadURL. They should all have your new domain in them. FileUploadURL should have your domain and /files after it. Change them if they need it, click “Save Settings”

After having completed all of that, I found that there was one additional small change I needed to make:
After setting up the Multi-Sites, WordPress gave me some code to add to the wp-config.php file. I had to remove a few of those lines from my wp-config file because it was causing links in the new sites to go back to the original site. You will only need to do this once:
define( ‘MULTISITE’, true );
define( ‘SUBDOMAIN_INSTALL’, false );
$base = ‘/’;
define( ‘DOMAIN_CURRENT_SITE’, ’3fc.co’ );  ####remove line define( ‘PATH_CURRENT_SITE’, ‘/’ );
define( ‘SITE_ID_CURRENT_SITE’, 1 );   ####remove line define( ‘BLOG_ID_CURRENT_SITE’, 1 );   ####remove line


Thats it. Your new site should be  using the new domain name. You can add as many sites and new domains as you want. In my next article I will write about setting up multiple FTP accounts for each of your new websites you add.

REFERENCES
http://ghettocottage.com/1041

http://wordpress.org/extend/plugins/wordpress-mu-domain-mapping/