Running multiple sites from one directory

You can run multiple client sites from a single software install.

This is handy if you are an ISP or web designer running several client sites, and you don't want to maintain a separate copy of the Zenario software for every client. This multi-site configuration saves a good deal of sysadmin work, while still allowing every client site to have its own customisations.

The Zenario software directory

You will want to select a directory for the Zenario software. For example, let's assume it is /var/www/zenario-source/Zenario-version, where version is replaced with the version number, say 7.0.2, 7.0.3 etc.

Here is a typical source installation directory:

[email protected]:/var/www/zenario-source/Zenario-7.0.2$ ls -la
total 68
drwxrwxr-x  9 siteadmin siteadmin 4096 Oct  6 12:45 .
drwxr-xr-x 32 siteadmin siteadmin 4096 Sep 11 16:28 ..
drwxrwxr-x  3 siteadmin siteadmin 4096 Jun  3 14:14 cache
-rw-rw-r--  1 siteadmin siteadmin   98 Aug 12 17:34 developer.txt
-rw-rw-r--  1 siteadmin siteadmin 2226 Sep  2 17:06 .htaccess
-rw-rw-r--  1 siteadmin siteadmin 2336 Sep  2 17:06 htaccess_for_tildes_in_home_dir.txt
-rw-rw-r--  1 siteadmin siteadmin   37 Jun  3 14:15 index.php
-rw-rw-r--  1 siteadmin siteadmin  101 Oct  6 12:45 js_minify
drwxrwxr-x  3 siteadmin siteadmin 4096 Jun  3 14:15 private
drwxrwxr-x  3 siteadmin siteadmin 4096 Jun  3 14:15 public
-rw-rw-r--  1 siteadmin siteadmin 3944 Oct  6 12:45 README.md
-rw-rw-r--  1 siteadmin siteadmin  149 Jun  3 14:15 robots.txt
drwxrwxr-x 11 siteadmin siteadmin 4096 Oct 10 12:13 zenario
drwxrwxr-x  4 siteadmin siteadmin 4096 Jun 24 11:50 zenario_custom
drwxrwxr-x 34 siteadmin siteadmin 4096 Oct  6 12:45 zenario_extra_modules

You will recall most of these directories and files from the description of the single-site directory structure. In this situation, zenario_custom is empty and there is no zenario_siteconfig.php file.

Do not attempt to point your Apache DocumentRoot here! This directory is treated as a library of software, not a real site.

The client directories

There can be one or more client directories. Each one contains files that are custom for that client.

If you allow FTP or SFTP access, this should be the home directory for the client user. (Note that we do not recommend this, unless you also use a chroot jail to prevent that user going to other parts of your server.)

Here is a typical client directory:

[email protected]:/var/www/clients/tribalsystems$ ls -l
total 16
drwxrwxrwx  2 siteadmin siteadmin 4096 Jan 14  2014 backup
drwxrwxrwx  2 siteadmin siteadmin 4096 Jan 14  2014 docstore
drwxrwxr-x 10 siteadmin siteadmin 4096 Sep 25 14:37 public_html

As with a single-site installation, there are the backup and docstore directories for the client user, and the public_html directory. This should be that client's DocumentRoot.

Inside public_html the contents look like this:

[email protected]:/var/www/clients/tribalsystems/public_html$ ls -la
total 40
drwxr-xr-x  5 siteadmin siteadmin 4096 Aug 21 11:28 blog
drwxrwxrwx 10 siteadmin siteadmin 4096 Jan 15  2014 cache
-rw-rw-r--  1 siteadmin siteadmin 2212 Jan 15  2014 .htaccess

lrwxrwxrwx  1 siteadmin siteadmin   51 Mar 31  2014 index.php -> ../../../zenario-source/Zenario-7.0.2/index.php
-rw-rw-r--  1 siteadmin siteadmin    0 Jan 14  2014 license.txt
drwxrwxrwx  5 siteadmin siteadmin 4096 Feb 25  2014 private
drwxrwxrwx  3 siteadmin siteadmin 4096 Feb 25  2014 public
-rw-rw-r--  1 siteadmin siteadmin  217 Jan 14  2014 robots.txt
lrwxrwxrwx  1 siteadmin siteadmin   49 Mar 31  2014 zenario -> ../../../zenario-source/Zenario-7.0.2/zenario
drwxrwxr-x  6 siteadmin siteadmin 4096 Aug  7 22:50 zenario_custom
drwxrwxr-x  2 siteadmin siteadmin 4096 Sep 18 17:42 zenario_extra_modules
-rw-rw-r--  1 siteadmin siteadmin 3701 Aug  7 14:55 zenario_siteconfig.php

How to set up a client directory

Here is how to set up a client directory, with symlinks to the main Zenario library. 

First, make a clients area, and a specific client, e.g.

cd /var/www
mkdir clients
cd client
mkdir example

Then go into that directory and prepare the directories as you would for a single site:

mkdir backup
mkdir docstore
mkdir public_html
chmod 777 backup
chmod 777 docstore

The above creates the public_html directory. This should be the DocumentRoot in your Apache config file. The backup and docstore directories must be writeable by the web server.

Now go inside public_html, and make the local directories and symlinks as follows:

mkdir cache
mkdir private
mkdir public
ln -s ../../../zenario-source/Zenario-7.0.2/.htaccess
ln -s ../../../zenario-source/Zenario-7.0.2/index.php
ln -s ../../../zenario-source/Zenario-7.0.2/zenario
ln -s ../../../zenario-source/Zenario-7.0.2/robots.txt
mkdir zenario_custom
mkdir zenario_custom/templates
mkdir zenario_custom/modules
mkdir zenario_custom/frameworks
mkdir zenario_custom/templates/grid_templates
chmod 777 cache private public zenario_custom/templates/grid_templates
touch zenario_siteconfig.php
chmod 666 zenario_siteconfig.php
touch license.txt

Your public_html directory should now look like this:

[email protected]:/var/www/clients/zenariohosting/public_html$ ls -la
total 24
drwxrwxr-x 6 siteadmin siteadmin 4096 Oct 16 08:00 .
drwxrwxr-x 5 siteadmin siteadmin 4096 Oct 16 07:30 ..
drwxrwxrwx 2 siteadmin siteadmin 4096 Oct 16 07:32 cache
lrwxrwxrwx 1 siteadmin siteadmin   47 Oct 16 07:56 .htaccess -> ../../../zenario-source/Zenario-7.0.2/.htaccess
lrwxrwxrwx 1 siteadmin siteadmin   47 Oct 16 07:56 index.php -> ../../../zenario-source/Zenario-7.0.2/index.php
-rw-rw-r-- 1 siteadmin siteadmin    0 Oct 16 07:56 license.txt
drwxrwxrwx 2 siteadmin siteadmin 4096 Oct 16 07:32 private
drwxrwxrwx 2 siteadmin siteadmin 4096 Oct 16 07:32 public
lrwxrwxrwx 1 siteadmin siteadmin   48 Oct 16 07:56 robots.txt -> ../../../zenario-source/Zenario-7.0.2/robots.txt
lrwxrwxrwx 1 siteadmin siteadmin   45 Oct 16 07:56 zenario -> ../../../zenario-source/Zenario-7.0.2/zenario
drwxrwxr-x 5 siteadmin siteadmin 4096 Oct 16 07:57 zenario_custom
-rw-rw-rw- 1 siteadmin siteadmin    0 Oct 16 08:00 zenario_siteconfig.php

Your Zenario software is now configured; you should now configure a database and user, configure your Apache config, and then run the browser-based installer.

Setting up additional client directories

Repeat the above process (How to set up a client directory) for each client.