Running Multiple Sites
User Manual » Advanced Topics » Running Multiple Sites
Running multiple sites (on the same server) can be quite a painful task when it comes to upgrading all of those to the latest version. Thankfully, TangoCMS makes running multiple sites using the same code base very easy, which this guide will show you.
Within this guide, we'll assume that the server is of a Unix/Linux variant, and that the two sites we want to run will be:
- example.com
- wiki.example.com
How TangoCMS Handles Profiles
The main 'config' directory within TangoCMS holds all of the profiles for different sites, and also a fall back profile called 'default'.
When TangoCMS loads, it first tries to find the correct config directory based on the domain name and path. For example, if you have TangoCMS installed at the root of 'example.com', it will try and find the config profile 'config/example.com', and if this directory is not found then it will use the 'default' profile.
Note (1): If you have TangoCMS installed in a place such as 'example.com/foobar' then TangoCMS will try and use 'config/example.com.foobar' as the profile (Anything none alphanumeric converted to a period).
Note (2): If you would like TangoCMS to be accessible at 'www.example.com' as well as 'example.com' then you will need to create a symlink to the 'example.com' profile, as explained later in this guide.
Setting up the Directory Structure
As we want to run 2 sites off the same code base, a common location for all of the files is needed. If you have full access to the server, a good place for this could be '/usr/tangocms'. However, if your access is limited then you could create the directory in your home folder, for example '~/usr/tangocms'.
Make the directory using the 'mkdir' command, such as:
mkdir /usr/tangocms
This directory will hold all of the files for TangoCMS, into which you can either extract the TangoCMS archive you downloaded, or use Subversion to checkout the latest code.
We highly suggest using Subversion, as this will make your TangoCMS installations even easier to maintain, as you can then easily switch to the latest TangoCMS release via one simple command. Use the following command to checkout the main TangoCMS repository.
svn co svn://tangocms.org/tangocms/tags/2.6.0/final/ /usr/tangocms/
Within your docroot for the sites example.com and wiki.example.com, you will also need to make a directory called 'tmp', to do this simply use the following:
mkdir /var/www/example.com/tmp /var/www/wiki.example.com/tmp
Creating the Needed Symlinks
Once you have the main TangoCMS code in your chosen location, you will need to allow the web server access the files for each site. This is achievable by creating three symbolic links to the appropriate directories and files, such as:
- html (directory)
- index.php
- .htaccess
Use the following commands to link the files (replace /usr/tangocms with your TangoCMS code location and replace /var/www/example.com/ with your web server's docroot for each of your sites)
ln -s /usr/tangocms/html /var/www/example.com/ ln -s /usr/tangocms/.htaccess /var/www/example.com/ ln -s /usr/tangocms/index.php /var/www/example.com/
As mentioned above, if TangoCMS is set up for the root of 'example.com' but you would also like it to be accessible at 'www.example.com' you will need to create one extra symlink so that the config files can be found for each:
ln -s /usr/tangocms/config/example.com /usr/tangocms/config/www.example.com
Everything should now be in place to run multiple sites from the same codebase. If, however, when you go to the actual website and it says the Install Directory is still present after installing it, you will have to chmod the 'install' directory so your webserver can not access it, for example:
chmod 0700 /usr/tangocms/install
Upgrading to Latest TangoCMS Version
It is always a good idea to keep your TangoCMS code updated to the latest version, to make sure you have the latest security updates and bug fixes. Running multiple sites from the same code base makes this a lot easier.
The first step you need to do is create another symlink to the 'install' directory, from within your website doc root, for example:
ln -s /usr/tangocms/install /var/www/example.com/ ln -s /usr/tangocms/install /var/www/wiki.example.com/
You will need to follow the instructions at the upgrade page, making sure you move the extracted files to the TangoCMS base directory, or if using Subversion, it is a simple matter of switching which repository the code is using (described in more detail in the Upgrade Manual)
Note: You will need to run the update script for each of your sites, by going to http://www.example.com/install/ and http://wiki.example.com/install/ etc. This will make sure that all your databases are upgraded.
Extra Notes
- All theme files should be kept in the html/themes directory of the codebase