Multitiki Akira

This is an installation guide, and it describes how to setup multiple tiki sites using one install but NOT using Virtual Hosting.
by Akira

In my example I am using Red Hat 7.3, apache 1.3.27-4, php-4.1.2-7.36, mysql-3.23.58-1.73.

The key to this example is that I want multiple sites but only under one hostname.

First setup your databases. I have chosen to create a separate mysql user and password for each database. You can do this or have a common user/password. If you have a common user/password you will need to change the code for local.php below. Make sure you follow all the steps for creating the databases as outlined in the INSTALL file. Also outlined here: RecipeMultiTiki. Don't forget to restart mysql.

I plan to put my single tikiwiki install in /var/www/tikiwiki/tikiwiki. Knowing this I setup my httpd.conf. I am going to use three subdirectories under my one hostname using aliases. Here is what one looks like, repeat however many times you want changing only the Alias line:

Alias /tiki-test1 "/var/www/tikiwiki/tikiwiki"
<Directory "/var/www/tikiwiki/tikiwiki">
       Options Indexes
       AllowOverride None
       Order allow,deny
       Allow from all
       ##### Overrides the php.ini setting for this directory
       #php_value phpa.cache_dir /tmp/phpa_eita_tiki
       # PHP settings to allow larger file uploads
       php_value max_execution_time 240
       php_value memory_limit 60M
       php_value upload_max_filesize 50M
       php_value post_max_size 60M
Please be careful with the php_value settings. Don't use these unless you know what they are doing.

Restart your webserver.

# service httpd restart

Get a distribution of Tikiwiki from sourceforge.net. Unpack it and place it where you want, creating directories if you haven't already done so.

# tar -xzvf tikiwiki-1.8.1.tar.gz
# mkdir /var/www/tikiwiki
# mv tikiwiki-1.8.1 /var/www/tikiwiki/tikiwiki
# ln -s tikiwiki/ tikiwiki-1.8.1 (I do this so I can quickly see what version I currently have installed)

Next we create the databases through the web install script. Load http://your-domain.com/tiki-test1/tiki-install.php. First fill in the first database and account information. Submit and go to the next screen. Chose the type of database you want to create or update and submit the form. Next click "Execute the Tiki installer again". Then click "Reset database connection settings" and enter your next install's database information. Rinse and repeat these steps for as many sites as you are creating. Once you have created the last site click "Rename/remove tiki install script and proceed to site."

We need to run setup.sh to setup the files and directories for tiki as well as for the multiple sites. Replace tiki-test1, tiki-test2 and tiki-test3 with the alias names you used above in httpd.conf.

# ./setup.sh apache apache 02755 tiki-test1 tiki-test2 tiki-test3

Now we want to edit db/local.php. The custom php below does what I want. It extracts the web path from the variable $_SERVER['SCRIPT_URL']. For each site you will need a "case" stanza. The case stanza should include database user/pass/name information as well as the tikidomain variable which we chose above when running setup.sh. If you want to have one mysql user/pass for all sites you would move the $user_tiki and $pass_tiki of the switch section, placing it just below $host_tiki.


$db_tiki     = 'mysql';
$dbversion_tiki = '1.8';
$host_tiki   = 'localhost';

switch ( extractTopPath( $_SERVER['SCRIPT_URL'] ) ) {
 case '/tiki-test1/':
  $user_tiki = 'tiki-test1';
  $pass_tiki = 'foobar1';
  $dbs_tiki = 'tiki-test1';
  $tikidomain = 'tiki-test1';
 case '/tiki-test2/':
  $user_tiki = 'tiki-test2';
  $pass_tiki = 'foobar2';
  $dbs_tiki = 'tiki-test2';
  $tikidomain = 'tiki-test2';

function extractTopPath( $in ) {
        if ( ( $point = strpos( substr( $in, 1 ), "/" ) ) === false ) return ( $in . "/" );
        return substr( $in, 0, $point + 2 );

I HIGHLY recommend making local.php read-only for user apache. Should you follow these steps later on for a new site and use the tiki-install.php web script to create a new database it WILL overwrite local.php.

Now you are ready to configure each site! Since tikiwiki uses cookies we have to make sure the cookies know which site you are at. To do this you need to login as admin and go to the Login administration page. Toward the bottom is HTTP(S) server name, HTTP(S) port and HTTP(S) URL prefix. You will want to fill the appropriate fields in. For my example site I would fill these fields in like this:

HTTP server namedomain.com
HTTP port80
HTTP URL prefixtiki-test1/

If you are going to use the remember me feature you will also want to fill out these fields: Remember me domain, Remember me path.
For my example site I would fill these fields in like this:

Remember me domaindomain.com
Remember me pathtiki-test1/

After that you should be able to login to each site and configure them and everything will be separated!

If you have any questions or suggestions please leave them in the comments of this page.


Related pages

Page last modified on Sunday 25 October 2009 19:48:21 GMT-0000

Upcoming Events

1)  Wed 23 Sep 2020 14:00 GMT-0000
September TRM

Why Register?

Register at tiki.org and you'll be able to use the account at any *.tiki.org site, thanks to the InterTiki feature. A valid email address is required to receive site notifications and occasional newsletters. You can opt out of these items at any time.