Vhosting: an alternative to WordPress multi-site

By Joe Gardiner Wednesday, 1st September 2010

catn-config

With the release of WordPress 3.0, multi-site functionality allows a network of sites to be managed by a single WordPress dashboard. Unfortunately some of our clients are having difficulties setting up a multi-site network, and WordPress.org codex is not always beginner friendly.

Vhosting offers an alternative by allowing multiple sites to be hosted on your single vCluster IP address. You can then use independent WordPress installs on each of these sites, decentralising a network and allowing you to manage each site manually.

We already have a guide for "vhosting" and "multiple domains on your vCluster", but you can follow the instructions here as well to setup multiple WordPress installs on vhosts.


Creating vhosts

To create a vhost you need to connect to your vCluster using SSH or FTP. In this article I will be using a visual FTP client, FileZilla, to visualise the process. If you do not know how to connect to your vCluster using an FTP client or by SSH, have a look at "setting up an FTP client", or "connecting with SSH".

Once you have connected to your vCluster navigate to:

/sites/fubra-customer/vhosts

Replace the fubra-customer with your own Passport Group, and vCluster name. Alternatively double click on the directories in FileZilla to find the vhosts folder visually.

vhost directory in FileZilla

Inside the vhosts folder you you can now create directories for each of the sites you wish to host on your vCluster. There is a very strict naming convention that you must follow in order for vhosting to work successfully.

The directory you create must have the exact same name as the domain name you wish to point here. For example, I have purchased the domain name joegardiner.co.uk, so in the vhosts folder I will create a directory named joegardiner.co.uk. Note, you will never need to add www to the front of the directory name.

creating a new directory using FileZilla

Now open your newly created vhost directory (joegardiner.co.uk), and inside this directory create a new directory named http. This directory will be the root directory for this vhost, similar to the http directory two levels higher in your main vCluster directory tree.

adding http directory to a vhost

Inside the newly created http directory you can install any php application you want, including WordPress. You can create as many vhosts as you want in this manner, but if you're installing multiple WordPress', it is very important you follow the next few steps.


Database table prefix

You vCluster is created with a single database, this means that multiple WordPress installs using this database may clash by trying to access the same tables, leading to instability. The solution is to change the table prefix each WordPress uses when you install it. Changing the prefix will allow you to easily see which set of tables applies to each vhost.

During the WordPress installation it is necessary to edit the "wp-config.php" file to add database information. If you unsure how to install WordPress have a look at this guide, "Install WordPress on your vCluster".

While editing the wp-config file you can also add a table prefix. Open up your wp-config file in a text editor and scroll down, near the bottom of the file. Find this block of code:

/**
 * WordPress Database Table prefix.
 *
 * You can have multiple installations in one database if you give each a unique
 * prefix. Only numbers, letters, and underscores please!
 */
$table_prefix  = 'wp_';

The 'wp_'; line is what you need to change to alter the table prefix. The table prefix must be made up of letters and numbers and underscores, and you can add anything you like between the single quotes, but I would recommend using a prefix that applies to your domain.

In my case my vhost is named joegardiner.co.uk, so I shall edit my prefix to read 'joegard_';. After editing this line the previous block of code should now look like...

/**
 * WordPress Database Table prefix.
 *
 * You can have multiple installations in one database if you give each a unique
 * prefix. Only numbers, letters, and underscores please!
 */
$table_prefix  = 'joegard_';

Once you have made the changes to the wp-config.php file you can save and exit your text editor and continue installing WordPress in the usual manner.


Pointing your domain

Now that WordPress is installed you need to point your domain name at your vCluster. Due to our clever Apache configuration, all you need to do is point each domain name for all of your vhosts at the single vCluster IP and the correct vhost will always be loaded, provided the directory naming rule was followed, and vhost directories exactly match domain names.

Every domain name registrant will use a different control panel for managing a domain name's DNS settings, I registered my domain with LivetoDot, so the following screenshot will be of their control panel.

First of all you need to head to the CatN Control Panel for your vCluster and take a look at the main settings page. Take a note of vCluster IP address as you will need this in a minute. Next head to your domain registrants site and login to the control panel. You will be editing the (A) Address record of your domain name which will be under DNS settings.

You want to overwrite or add records for "www" and an empty field. Have a look at the screenshot below for help.

Changing DNS settings for vCluster IP address

Once you save these two records, it may take up to 24 hours to update a .co.uk domain name so be patient! Once the (A) record is updated, navigating to your domain name in your web browser, in my case www.joegardiner.co.uk, will load the files from the joegardiner.co.uk vhost directory we created earlier.



You can follow the previous procedure as many times as you want for as many independent WordPress installs as you require. The benefit is that you can manage installs separately without the confusion caused by a centralised user, theme and plugin management system. On the down side you may have to repeat configuration across each WordPress manually instead of being able to activate plugins across the network.

Fortunately your vCluster happily supports both methods, so whichever process you prefer for setting up your WordPress network, it will be fully compatible with our php optimised hosting platform.


Posted in Guides, vHosting | No Comments » twitter-follow facebook-follow rss-follow

Leave a Reply

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