User:PeteE > Multi-Tenant Setup

Multi-Tenant Setup

This is a quick FAQ on running dekiwiki in a multi-tenant configuration.  Note, this functionality is only available in Deki Wiki 1.8.3 and greater.


Edit your mindtouch.deki.startup.xml (in /etc/dekiwi) and add new <config> elements beneath the <wikis> element:

mindtouch.deki.startup.xml

<script>
  <!-- register Deki services -->
  <action verb="POST" path="/host/load?name=mindtouch.deki" />
  <action verb="POST" path="/host/load?name=mindtouch.deki.services" />
  <action verb="POST" path="/host/load?name=mindtouch.indexservice" /> 

  <!-- start Deki services -->
  <action verb="POST" path="/host/services">
    <config>
      <wikis>
          <config id="wiki1.example.org">
	          <host>wiki1.example.org</host>
	          <host>wiki1alias.example.org</host>  <!-- this is an alias similar to how Apache VirtualHost works -->
              <db-server>localhost</db-server>
              <db-port>3306</db-port>
              <db-catalog>wiki1</db-catalog>
              <db-user>wikiuser</db-user>
              <db-password hidden="true">yourpass</db-password>
              <db-options>pooling=true; Connection Timeout=5; Protocol=socket; Min Pool Size=2; Max Pool Size=50; Connection Reset=false;character set=utf8;ProcedureCacheSize=25;Use Procedure Bodies=true;</db-options>
          </config>
          <config id="wiki2.example.org">
	          <host>wiki2.example.org</host>
              <db-server>localhost</db-server>
              <db-port>3306</db-port>
              <db-catalog>wiki2</db-catalog>
              <db-user>wikiuser</db-user>
              <db-password hidden="true">yourpass</db-password>
              <db-options>pooling=true; Connection Timeout=5; Protocol=socket; Min Pool Size=2; Max Pool Size=50; Connection Reset=false;character set=utf8;ProcedureCacheSize=25;Use Procedure Bodies=true;</db-options>
          </config>
          <globalconfig>
          <!-- this section allows you to set/override any value in the wiki's config table
               For example, if you'd like to override the ui/analytics-key (google anlaytics) for all wikis, you could add this:
               <ui>
                   <analytics-key>UA-68075-12</analytics-key>
               </ui>
          -->
          </globalconfig>
      </wikis>

      <!-- Service startup -->
      <!-- deki: relative path for deki-api service. I.e., http://host/deki -->
      <!-- sid: the serviceid points to a class that represents the service for startup-->
      <path>deki</path>
      <sid>http://services.mindtouch.com/deki/draft/2006/11/dekiwiki</sid>

      <deki-path>/var/www/dekiwiki</deki-path>
      <imagemagick-convert-path>/usr/bin/convert</imagemagick-convert-path>
      <imagemagick-identify-path>/usr/bin/identify</imagemagick-identify-path>
      <imagemagick-timeout>30000</imagemagick-timeout>

      <api-key>12345</api-key>
      
      <indexer>
        <path.store>/var/www/dekiwiki/bin/cache/luceneindex/$1</path.store>  <!-- $1 will be replaces with the wiki id (ex: wiki2.example.org) -->
        <filter-path extension="doc">/var/www/dekiwiki/bin/filters/wvText</filter-path>
        <filter-path extension="pdf">/var/www/dekiwiki/bin/filters/pdf2text</filter-path>
        <filter-path extension="xhtml">/var/www/dekiwiki/filters/html2text</filter-path>
        <filter-path extension="html">/var/www/dekiwiki/bin/filters/html2text</filter-path>
        <filter-path extension="htm">/var/www/dekiwiki/bin/filters/html2text</filter-path>
        <filter-path extension="docx">/var/www/dekiwiki/bin/filters/docx2txt</filter-path>
        <filter-path extension="odt">/var/www/dekiwiki/bin/filters/odt2txt</filter-path>
        <filter-path extension="odp">/var/www/dekiwiki/bin/filters/odp2txt</filter-path>
        <filter-path extension="ppt">/var/www/dekiwiki/bin/filters/ppt2txt</filter-path>
        <filter-path extension="pptx">/var/www/dekiwiki/bin/filters/pptx2txt</filter-path>
        <filter-path extension="xls">/var/www/dekiwiki/bin/filters/xls2txt</filter-path>
        <filter-path extension="pl"></filter-path>
        <filter-path extension="c"></filter-path>
        <filter-path extension="h"></filter-path>
        <filter-path extension="inc"></filter-path>
        <filter-path extension="php"></filter-path>
        <filter-path extension="cs"></filter-path>
        <filter-path extension="txt"></filter-path>
        <filter-path extension="csv"></filter-path>
        <filter-path extension="xml"></filter-path>
        <filter-path extension="xsl"></filter-path>
        <filter-path extension="xslt"></filter-path>
      </indexer>
      </config>
  </action>
</script>

Create your LocalSettings.php

<?php

$IP = "/var/www/dekiwiki";
ini_set( "include_path", ".:/var/www/dekiwiki:/var/www/dekiwiki/includes:/var/www/dekiwiki/languages" );
require_once( "includes/DefaultSettings.php" );

$wgDekiApiKey = "12345";

// this section is required for performing database updates via maintenance/update-db.php
$wgWikis = array(
        'wiki1.example.org' => array(
                'db-server' => 'localhost',
                'db-port' => '3306',
                'db-catalog' => 'wiki1',
                ),
        'wiki2.example.org' => array(
                'db-server' => 'localhost',
                'db-port' => '3306',
                'db-catalog' => 'wiki2',
                ),
);

?>

Create the wiki database

To create a new database, we have a script in maintenance/createdb.sh

petee@host:/var/www/dekiwiki/maintenance$ ./createdb.sh 
Usage: ./createdb.sh: --dbName database_name --dbAdminUser database_admin_user \
 --dbAdminPassword database__admin_password --dbServer database_server \
 --dbWikiUser database_wiki_user --wikiAdmin admin_login \
 --wikiAdminPassword admin_password --wikiAdminEmail admin_email \
 [--maintenanceDir wiki_maintenance_directory]

Parameters:
--dbName:  Name of the database catalog to create.
--dbAdminUser: The database admin user used to create the database.
--dbAdminPassword: The password for the database admin user.
--dbServer: The MySQL host where the database will be created. 
--dbWikiUser: The non-admin mysql account for the wiki database.
--wikiAdmin: The name of the Deki Wiki administrator account.
--wikiAdminPassword: The password for the Deki Wiki administrator account.
--wikiAdminEmail: The email address for the Deki Wiki administrator account.

OPTIONAL Parameters:
--maintenanceDir: Deki Wiki maintenance directory
--storageDir: The path to the file storage directory
--s3PublicKey: S3 public key
--s3PrivateKey: S3 private key
--s3Bucket: S3 bucket
--s3Prefix: prefix for all files stored on S3.  Allows multiple wikis to share the same bucket
--s3Timeout: timeout for S3 requests
 

Here's an example invocation:

./createdb.sh --dbName wiki1 --dbAdminUser root --dbAdminPassword root_mysql_pass \
 --dbServer localhost --dbWikiUser wikiuser --wikiAdmin Admin \
 --wikiAdminPassword my_wiki_admin_password --wikiAdminEmail petee@mindtouch.com \
 --storageDir /var/www/dekiwiki/attachments/wiki1

NOTE: If the "wikiuser" doesn't exist in your mysql server the user will be created but have a blank password so please remember to set a password! 

Create /etc/init.d/dekiwiki init script

If you've already got a single-tenant wiki you shouldn't need to do anything else here.  If you're starting from scracth, use the web installer to generate them for the first wiki.

 

Apache configuration

You can use a single apache configuration with multiple wikis by modifying your VirtualHost configuration and adding the ServerAlias directive:

 <VirtualHost *:80>
    ServerName dekiwiki
    ServerAlias wiki1.example.org
    ServerAlias wiki2.example.org
    #ServerAlias *    # note, this will match all Host headers 

    DocumentRoot /var/www/dekiwiki 
 
    <!-- snip -->

 

 

Tag page
Viewing 10 of 10 comments: view all
If you have multiple instances like this, I suppose the searching will be site-by-site only, correct?

Also - if one decided not to go for multi-tenant, but yet needed to keep certain groups of users separate, it appears you can do this with roles and permissions. However, does searching follow the rules? If user X can use only sub-page X and its children, when user X searches, can s/he see user Z's pages?
Posted 11:41, 7 Nov 2007
We have a separate search index per wiki site (instance). In the near future we'll implement cross-instance search.

The search function does respect user permissions so you shouldn't see any search results for pages/files that you can't view.
Posted 16:12, 30 Nov 2007
Thanks, PeteE, this worked. I had some attachments in a normal filesystem directory, but when I moved to multi, I switched to S3 for storage. I copied up my attachments folder contents to the folder in S3, and the numbers were wrong, or were not what was expected. Is there a way to migrate from normal fs to S3?
Posted 14:08, 1 Dec 2007
Also, now that it is working, I was thinking about how do I repeat the process for 20 sites easily. I noticed maintenance/createsite.sh, but would you be so kind as to comment on how this works, or if I can use it to create sites?
Posted 23:51, 1 Dec 2007
Hi Pete, the createdb.sh is no longer available in trunk, which I switched to. Is this by design? Can we get it back? I need to make a couple more wikis...

Thanks
Rick
Posted 09:57, 14 Dec 2007
--storageDir /var/www/attachments/wiki1 ??

should it not be something like this?

--storageDir /var/www/wiki1
Posted 05:14, 15 Jan 2008
Does the Windows XP Desktop connector work with multi tenant?
Posted 19:27, 25 Jan 2008
Hope you don't mind. I updated the createdb.sh examples so that they will wrap and be printable... :)

Piko edited 00:10, 4 Mar 2008
Posted 00:10, 4 Mar 2008
file locations:
/etc/dekiwiki/mindtouch.deki.startup.xml

/var/www/dekiwiki/LocalSettings.php

/etc/apache2/httpd.conf (In this file the closing tag is missching: </VirtualHost>

/var/www/dekiwiki/maintenance from this dir type: ./createdb.sh etcetera edited 11:23, 24 Jul 2008
Posted 11:20, 24 Jul 2008
If you want to serve different favicons for multiple wikis, you can use this redirect directive for each wiki (add it to VirtualHost configuration of Deki after other rewrites:

RewriteCond %{HTTP_HOST} ^wiki.example.org$
RewriteRule ^/favicon\.ico$ /favicon-you-want.ico [T=image/x-icon,L]
Posted 13:04, 11 Sep 2008
Viewing 10 of 10 comments: view all
You must login to post a comment.
Powered by MindTouch Deki v.8.08.1a