Skip to main content

Multi sites

If you are running multiple Tuskfish websites off one hosting account, you may find it convenient to run them all off a single code base. It makes maintenance a lot easier since you only have to apply patches, upgrades and your own hacks once. It also simplifies backups and cuts down time on FTP transfers, etc.

To summarise, each of your sites can use a common trust_path back end, drawing on the code libraries and directory structure in there. However, they do need to keep a unique front end file structure (the files in each site's public_html or web root), as you are likely to customise those. The main issue is that you need to set up separate configuration files for each site, as well as separate file cache and uploads directories, to prevent them overwriting one another.

Here's how to set up multi sites with a single back end code base:

  • Install your first Tuskfish website as per usual. No need to do anything different.
  • Create subdirectories in your web root (public_html) to house your additional sites.
  • In your second (and subsequent) website installation, you only need to upload the front end files (do not upload the trust_path, as you will use the existing one you created for the first site).
  • Edit mainfile.php in your second site to set the base file path constants, as usual. However:
  • Set the TFISH_TRUST_PATH constant to point at the trust_path of the first website, which will be used for all sites.
  • Set the TFISH_CONFIGURATION_PATH to point at a copy of config.php that you have renamed. For example, the configuration path is usually this:
define("TFISH_CONFIGURATION_PATH", TFISH_TRUST_PATH . "configuration/config.php");

If I were setting up a second hypothetical site called flatfish.org, I might change it to something unique like:

define("TFISH_CONFIGURATION_PATH", TFISH_TRUST_PATH . "configuration/flatfish_config.php");
  • Upload a corresponding copy of the config file (flatfish_config.php in this example) to the trust_path/configuration directory.
  • Edit your new config file (flatfish_config.php) and change the private cache path to be unique:
define ("TFISH_PRIVATE_CACHE_PATH", TFISH_TRUST_PATH . "cache/");

Change it to something like:

define("TFISH_PRIVATE_CACHE_PATH", TFISH_TRUST_PATH . "cache/flatfish/");
  • Create a matching subdirectory, eg. trust_path/cache/flatfish in this example.
  • Similarly, edit the TFISH_ERROR_LOG_PATH to create a separate logfile for your additional site, eg:
define("TFISH_ERROR_LOG_PATH", TFISH_TRUST_PATH . "log/flatfish_log.txt");

Tuskfish 2

If you plan on having any custom routes on your site, then you should also create a separate routing table for each site. Make a copy of trust_path/libraries/tuskfish/routingTable.php. Edit index.php to refer to the new file:

// Specify a unique routing table for each site.
$routingTable = require_once TFISH_PATH . 'flatfishRoutingTable.php';

Finishing up:

  • Optional: If you wish to customise the language files for a particular site, then you should also make a copy of english.php with a different name (eg. flatfish_english.php) and edit the configuration file path to point at it.
  • Run the installation script for the second site, as usual, but make sure you give the database a unique name, so that it does not overwrite the earlier sites.

That's it. All of the databases will be stored in trust_path/database and coexist quite happily. If you ever need to update the Tuskfish library or some other shared component in the trust_path, you only need to do it once and the change will apply across all of your sites.

Copyright, all rights reserved.

Related

Tuskfish CMS User Manual

The user manual provides a comprehensive guide to Tuskfish CMS operations. It covers all all aspects from installation to adding and curating content, managing site security and customisation of themes. For additional information on how to customise Tuskfish please see the developer guide.