HOWTO: Setup Habari Multi-Site on Joyent
I think one of the greatest features of Habari is it's multi-site support. Unlike Wordpress, Habari has multi-site support out of the box. This allows you to configure multiple blogs off a single installation of the code with a fair amount of control over how independent each of these blogs are.
Each new blog can have it's own domainname (they don't even have to be subdomains), database, themes and plugins. However, if you prefer, they can all share the same set of themes and plugins too thus making managing and maintaining all of your sites a very simple affair.
In this post I'll detail how you can take advantage of this functionality on Joyent's Shared Accelerator hosting without using up more than one of your allowed "websites", thanks to aliasing and Habari.
Whilst these instructions are based on Joyent's hosting plan, they may be very similar for your hosting plan too. Let me know if these instructions work for your hosting solution too.
Habari Installation
Naturally, you have to have your first instance of Habari installed. This is the base installation that will be used for all your other sites too. I've detailed this step in an earlier post - Install Habari On Joyent.
This is also the step where you use up one, and only one, of your allocated "websites".
Configure Habari
Once you've got your base instance installed and running, creating the other sites is very quick and easy.
NOTE: These instructions assume you've installed Habari into a new domain called "domain1.tld" directly into the "public" directory and that you are going to create a new site called "domain2.tld".
- SSH to your account on your Joyent server and change into the base Habari installation directory:
$ cd ~/domains/domain1.tld/web/public/
- Within this directory is the "user" directory which is used to hold your own custom code, plugins, themes and sites. The sites directory doesn't exist by default, so we'll need to create this. We'll also need to create a directory for the new site. The new site's directory name needs to conform with naming rules defined here.
So lets create the site directory in one simple command:
$ mkdir -p user/sites/domain2.tld - Now at the very least, this new site subdirectory just needs a config.php file. This file must be empty and writable by you (as the webserver process runs under your user ID). You can create this file as follows:
$ touch user/sites/domain2.tld/config.php
That's it for the command line work. Now to configure the hosting settings via Virtualmin.
Configure Virtualmin
- Open up Virtualmin in your web browser and select your base Habari domain from the drop down, in this example "domain1.tld"
- Click "Create Virtual Server". This will open up the "Create Virtual Sub-Server" form in the right window. Now DON'T enter anything yet.
- In the form that opens on the right, you should see a link at the very top that reads "Alias of ...". Click this link. This will change the form on the right to a much simpler form.
- Enter the new domain name, as you wish to access it from the internet, eg "domain2.tld", enter a description if you wish and select "Enable PowerDNS domain?" in the "Enabled Features" section.
- Click "Create Server". This will create the virtual server alias, but it won't be enabled.
- To enable it, select the alias from the drop down menu in the right hand column and wait for the screen to refresh.
- Click "Edit Virtual Server" and then select "Web virtual server enabled?" in the "Enabled Features" section
- Click "Save Virtual Server" and allow the page to refresh. This may take a bit of time.
Once Virtualmin returns, you're all set to go. Configure your domain name to point to the Joyent DNS servers and then visit your new website and run through the normal Habari installation/configuration steps.
You can repeat these steps for each additional site. Just be warned: you will still be limited by the Joyent usage restrictions WRT CPU, memory and bandwidth, but you won't be limited by the number of websites anymore.