Jump to navigation Jump to search
This page is a translated version of the page Manual:Wiki family and the translation is 33% complete.
Other languages:
Deutsch • ‎English • ‎Türkçe • ‎español • ‎français • ‎polski • ‎português • ‎português do Brasil • ‎svenska • ‎русский • ‎فارسی • ‎हिन्दी • ‎中文 • ‎日本語 • ‎한국어

Unten wird aufgezeigt, wie MediaWiki konfiguriert werden kann, damit mehrere Wikis auf demselben Server laufen können. Mehrere Wikis, die sich auf demselben Server befinden, werden als Wiki-Familie oder Wiki-Farm bezeichnet. Eine Liste bekannter Wiki-Familien ist auf WikiApiary verfügbar.

Allgemeine Grundsätze

Bei den meisten Konfigurationen von Wiki-Familien läuft eine einzige Instanz von MediaWiki. Die folgenden allgemeinen Schritte sind in diesem Szenario nötig:

  1. Install a normal MediaWiki site, and create a database template from it. This can either be completely empty (i.e. no rows in any tables) or can have whatever initial pages, users, interwiki links, etc. that you want in any new member of the family.
  2. Set up your web server to route traffic from multiple places to the one MediaWiki installation. This can be for multiple domains, subdomains, or subdirectories, and can be done with symlinks, aliases, URL rewriting, or other mechanisms.
  3. Konfiguriere die "Familie" in der Datei LocalSettings.php in vier großen Abschnitten:
    1. Zunächst verwende $_SERVER['SERVER_NAME'] oder $_SERVER['REQUEST_URI'] (oder ähnlich) und die Konstante MW_DB (und Umgebungsvariable), um die verschiedenen Wikis zu identifizieren (beispielsweise als Variable mit dem Namen $wikiId). Die Ersteren sind für Web-Anfragen und die Letzteren für Wartungsskripte (denen der Parameter --wiki übergeben werden sollte). Nicht zu vergessen, an dieser Stelle einen netten Hinweis anzubringen, wenn das Wiki nicht identifiziert werden kann.
      if ( defined( 'MW_DB' ) ) {
          // Set $wikiId from the defined constant 'MW_DB' that is set by maintenance scripts.
          $wikiId = MW_DB;
      } elseif (isset($_SERVER['SERVER_NAME']) && $_SERVER['SERVER_NAME'] == '') {
          // Add a value to the $wikiId variable for e.g.
          $wikiId = 'wiki1';
      } elseif (isset($_SERVER['SERVER_NAME']) && $_SERVER['SERVER_NAME'] == '' && substr($_SERVER['REQUEST_URI'], 0, 6) == '/wiki2') {
          // Add a value to the $wikiId variable for e.g.
          $wikiId = 'wiki2';
      } else {
          // Fail gracefully if no value was set to the $wikiId variable, i.e. if no wiki was determined
          die( 'It was not possible to determine the wiki ID.' );
    2. Dann sind die Konfigurationsvariablen einzurichten, die auf der Wiki-Ident basieren. Dazu gehören:
      $wgDBname = 'mediawiki_'.$wikiId;
      $wgDBuser = 'mediawiki_'.$wikiId;
      $wgCacheDirectory = "/tmp/mediawiki_".$wikiId."_cache";
      $wgUploadDirectory = "$IP/images_$wikiId";
      $wgUploadPath = "/images_$wikiId";
    3. Danach sind die Konfigurationsvariablen festzulegen, die für jedes Wiki unterschiedlich sind. Dazu gehören:
      if ($wikiId == 'wiki1') {
          $wgSitename = "Wiki name";
          $wgServer = "";
          $wgLogo = "ExampleWiki_logo.png";
          $wgDBpassword = "we39485f7ha34";
          $wgSecretKey = "9348vhas589ytas35aurhgao94aywrotuhapw94u";
          $wgLanguageCode = 'pt';
      These could also be included from a separate file, e.g. LocalSettings_$wikiId.php.
    4. Schlussendlich werden in der Datei LocalSettings.php alle gemeinsamen Aspekte, wie Erweiterungen, Skins und anderes konfiguriert.
  4. Shared resources can be configured, such as users, sessions, media (i.e. uploads), interwiki links, etc.
  5. Installing a new wiki in the family is a matter of creating the database and importing the database template, and then running php maintenance/update.php --wiki=wikiId. Upgrades and other maintenance tasks are similar.

The rest of this page elaborates on (or will do[update required]) the various parts of the above.

Riesige Switch-Anweisung

This will allow you to install more than one wiki on a single server, using the same source code checkout.

  1. Die MediaWiki-Dateien in einen Webordner des Webservers hochladen.
  2. Das erste Wiki wie gewöhnlich aufsetzen. Für Einzelheiten siehe Handbuch:Installationsanleitung .
  3. Nach erfolgreicher erfolgreicher Installation ist die LocalSettings.php -Datei in dem Stammverzeichnis des Wikis abzulegen und derart umzubenennen, dass es leicht nachzuvollziehbar ist (z.B. LocalSettings_meinErstesWiki.php)
  4. Die Schritte zwei und drei sind für jedes zu erstellende Wiki zu wiederholen, wobei jedes Mal eine neue LocalSettings.php-Datei für jedes Wiki erstellt wird (z.B. LocalSettings_einWeiteresWiki.php).
  1. If two or more separately installed wikis are to be merged to operate out of files of the main wiki, then after renaming and moving each of your LocalSettings.php files to the main wiki folder, change the variable $wgScriptPath in each of the LocalSettings.php files to point to the main wiki's folder.
  1. Create a LocalSettings.php file for your global settings, then select one from the two possibilities below:
  • If you have different (sub)domains that link to one directory on your server, use this:
// Include common settings to all wikis before this line (eg. database configuration)

        switch ( $_SERVER['SERVER_NAME'] ) {
                case '':
                        require_once 'LocalSettings_shoopz_com.php';

                case '':
                        require_once 'LocalSettings_help_shoopz_com.php';

                case '':
                        require_once 'LocalSettings_wiki_shoopz_net.php';

                        header( 'HTTP/1.1 404 Not Found' );
                        echo 'This wiki is not available. Check configuration.';
                        exit( 0 );
To set up multiple domains that point to the same MediaWiki code, you may need to modify your web server and possibly DNS configuration. See the documentation of your web server and or web host for information on how to do that.
  • If your wikis are on the same domain but different paths (e.g., etc), you can use something like this:
// Include common settings to all wikis before this line (eg. database configuration)

$callingurl = strtolower( $_SERVER['REQUEST_URI'] ); // get the calling url
if ( strpos( $callingurl, '/wiki1' )  === 0 ) {
        require_once 'LocalSettings_wiki1.php';
} elseif ( strpos( $callingurl, '/wiki2' ) === 0 ) {
        require_once 'LocalSettings_wiki2.php';
} elseif ( strpos( $callingurl, '/wikiN' ) === 0 ) {
        require_once 'LocalSettings_wikiN.php';
} else {
        header( 'HTTP/1.1 404 Not Found' );
        echo "This wiki (\"" . htmlspecialchars( $callingurl ) . "\") is not available. Check configuration.";
        exit( 0 );
If you use Short URL with the second case (directory based wikis), you need to check the two directories: strpos( $callingurl, 'wiki1', 0 ) || strpos( $callingurl, 'w1/', 0 ), to symlink the sources (w1 -> w), and adapt $wgScriptPath.

It is recommended to use a different DB for each wiki (By setting a different $wgDBname for each wiki). However if you are limited to a single database, you can use a different prefix ($wgDBprefix ) to separate the different installs.

It may also be useful to simply redirect any unrecognized wiki URL to the "main" url, instead of "This wiki is not available. Check configuration."

Wiki-Familien von der Kommandoziele aktualisieren

EXPORT verwenden

This method requires the $_SERVER["SERVER_NAME"] to be present to run maintenance/update.php - which of course it isn't, from the commandline. This can be overcome by setting an environment variable:
php update.php

If you were using the subdirectory method, you can use:

php update.php

conf-Parameter verwenden

If you are using a separate LocalSettings.php file for each wiki in the family, as suggested in Giant switch statement, then you can use the --conf parameter to tell update.php which settings file to use. For instance:

php update.php --conf ../LocalSettings_shoopz_com.php

Drupal-style sites

As above, this setup allows you to install more than one wiki using different databases on a single server, using the same source code. This setup has the advantage of being completely transparent to users and reasonably secure in terms of the images directory.

  1. Create a base directory to contain all your MediaWiki files e.g. mkdir /home/web/mediawiki.
  1. Install MediaWiki and additional tools as usual to a version-declaring subdirectory (e.g., /home/web/mediawiki/mediawiki-1.10.0).
  2. Link the version-declaring directory to a code directory. e.g., ln -s /home/web/mediawiki/mediawiki-1.10.0 /home/web/mediawiki/code
  3. Create a sites directory to contain our images and settings: mkdir /home/web/mediawiki/sites
  4. Setup the wiki as normal from the /code directory.
  5. After successful installation, move LocalSettings.php into a sites directory that will be a match when the site is checked. For example, to capture, one would create the directory e.g., mkdir /home/web/mediawiki/sites/ See the Drupal's settings.php file for more information on this.
  6. If you intend to use media files, create an images directory in your site directory. e.g., mkdir /home/web/mediawiki/sites/ Make it writable as necessary.
  7. Place the Drupal-style LocalSettings.php file in your main directory: cp DrupalLocalSettings.php /home/web/mediawiki/code/LocalSettings.php
  8. Modify the LocalSettings.php of each subsite to point to the right places:
    1. First comment out the code relating to $IP, (lines 16-20 in 1.15.3) as this is set to the code directory by index.php.
    2. Next insert the following two lines to ensure that image files are accessible, e.g.: $wgUploadDirectory = "/home/web/mediawiki/sites/"; and $wgUploadPath = "/images";. These need to be put somewhere after the call to DefaultSettings.php (line 25 in 1.15.3), as the variables will otherwise be reset.
    3. Make further modifications as required.
  9. Prepare your Apache 2 installation. Example site:
    1. Create a link to the code directory, if required e.g. ln -s /home/web/mediawiki/code /home/web/
    2. Create an appropriate VHost configuration:
<VirtualHost *:80>
    DocumentRoot /home/web/
    CustomLog /var/log/apache2/wiki.mysite.log common
    # Alias for the site to be accessible
      Alias /mediawiki/code /home/web/mediawiki/code
    # Alias for Wiki so images work
      Alias /images /home/web/mediawiki/sites/
    # If you want to password protect your site
    #  <Directory /home/web/>
    #    AuthType Basic
    #    AuthName "My protected Wiki"
    #    AuthUserFile /etc/apache2/htpasswd/users-mywiki
    #   require valid-user
    #  </Directory>
11. If you are setting the sites up locally, update your hosts file with the site names. Die Seite sollte nun funktionieren

In my case, I made another copy of the code from which to install and update my LocalSettings.php and databases. Note that $_SERVER['HTTP_HOST'] in the companion Drupal code is undefined when running maintenance scripts from the command line, so this solution does not permit the use of maintenance scripts without some modification.

Modified Drupal-style method for Ubuntu

A simplified method for multiple wikis and multiple (or nested) subwikis on Ubuntu/Kubuntu that is loosely based on the above method can be found at:

Mehrere Wikis teilen sich gemeinsame Ressourcen

Einigen Wikis in verschiedenen Sprachen sollen die gleichen Mediendateien in einem weiteren, gemeinsamen Wiki zur Verfügung gestellt werden.

Zum Beispiel:

  • - Englisch
  • - Französisch
  • - Deutsch
  • - Medien-Dateien für all diese Wikis (wie Commons).
    • Think before being creative; if you call your media-files-wiki something like "media" (e.g., it might collide with internal namespaces and nomenclature for embedded media files ([[media:file.ext]]).


Im Dateisystem einen Ordner für jedes Wiki erstellen. Das Installationsskript für jedes Wiki ausführen.

Diese Lösung dupliziert Quellcode. To reduce this duplication and improve cache performance, you may wish to replace the bin (≤ MW 1.20.x), docs, extensions, includes, languages, maintenance, math (≤ MW 1.17.x), resources, serialized[1], skins, tests and vendor (≥ MW 1.22.x[2]) directories for non-pool installations with symbolic links to the pool's directories:

This will not work as of version 1.32.4. LocalSettings.php is loaded by includes/Setup.php.
if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
        call_user_func( MW_CONFIG_CALLBACK );
} else {
        if ( !defined( 'MW_CONFIG_FILE' ) ) {
                define( 'MW_CONFIG_FILE', "$IP/LocalSettings.php" );
        require_once MW_CONFIG_FILE;

The global variable $IP, in turn, is defined in includes/WebStart.php,

# Full path to the installation directory.
$IP = getenv( 'MW_INSTALL_PATH' );
if ( $IP === false ) {
        $IP = dirname( __DIR__ );

which is called by the following code in index.php

require __DIR__ . '/includes/WebStart.php';
The software demands an absolute, not a relative path for LocalSettings.php, regardless of web server settings. This is not a practical way to allow for deduplication of code by using symlinks.


For example, enter
rm -R extensions/
and then enter
ln -s pathtopool/extensions/ extensions
Don't forget to allow your Apache to Follow Symbolic Link editing your httpd.conf adding FollowSymLinks options
However, you should not replace the cache, mw-config(config ≤ MW 1.16.x) and images directories.
To do the same in Windows, use
mklink /D pathtolink pathtotarget



It is imperative, that you modify LocalSettings.php of your different wiki installations right from the start (even before creating the symbolic links) , or you will have /wiki/../maintenance/runJobs.php --maxjobs 1 piling up in your server's memory. Fügen Sie die nachstehende Zeile in jede LocalSettings.php ein.
$wgJobRunRate = 0;


Jetzt sind Interwikilinks zwischen allen Wikis setzen, etwa indem man deren MySQL-Datenbanken bearbeitet (man kann auch Erweiterung:Interwiki installieren und benutzen)

  • Tabelle Interwiki
    • iw_prefix - hier muss der Sprachcode des zu verlinkenden Wikis eingegeben werden, also "de" für deutsch, "en" für english, "fr" für französisch und "pool" für die Bildersammelstelle
    • iw_url - hier muss die direkte URL auf die entsprechenden Wiki gesetzt werden, also z.B. "$1" für die englische Version (das "$1" nicht vergessen !!!).

Es sind so viele Datensätze in die Tabelle Interwiki einzutragen, wie es verschiedene Wikis gibt (also beispielsweise einen Datensatz für Deutsch, einen für Englisch, einen das gemeinsame Medien-Wiki).

Ist dies, können die Artikel der einzelnen Wikis untereinander verlinkt werden. Beispielsweise kann von der Hauptseite des deutschen Wikis per [[en:Main Page]] auf die englische Hauptseite verlinkt werden. Für weitere Informationen siehe Help:Interwiki linking

Note to page Special:Interwiki: (you will see a long table)
Add in the German wiki the prefix 'en' and the url$1 and set the checkbox 'Als lokales Wiki definiert'.
Do it in the English wiki vice versa with checkbox 'Forward'. And in both wikis enter a second prefix 'pool' and$1 and check the checkbox 'Forward'.


Stelle sicher, dass der "images"-Ordner des PoolWikis beschreibbar ist.

Jetzt sollten die Sprach-Wikis so eingestellt werden, dass der "Upload"-Link auf die Uploadseite des Pool-Wikis verweist. Dies macht man, indem man in den "LocalSettings.php" der Sprachwikis folgendes hinzufügt:

$wgUploadNavigationUrl = "";

In 1.17, you'll also have to set $wgUploadMissingFileUrl to be redirected to the pool-wiki on red links.

$wgUploadMissingFileUrl= "";

Gemeinsame Dateien verwenden

Damit die Sprachwikis die Dateien des PoolWikis benutzen können, muss ebenfalls in jeder "LocalSettings.php" der Sprachwikis hinzugefügt werden:

$wgUseSharedUploads = true;
$wgSharedUploadPath = '';
$wgSharedUploadDirectory = '/(LOCALPATH)/POOL-FOLDER/images/';
$wgHashedSharedUploadDirectory = true;

Now you can integrate pool's files with (e.g. [[Image:MyLogo.png]]) in the languagewikis.


In each languagewiki, open (as an admin) the message MediaWiki:Sharedupload-desc-here.

Change the text to something like:

<span lang="en" dir="ltr" class="mw-content-ltr">This file is stored in our data-pool.</span> 
<span lang="en" dir="ltr" class="mw-content-ltr">For information and description, please visit the</span>

<div lang="en" dir="ltr" class="mw-content-ltr">
[[:pool:Image:{{PAGENAME}}|description there]].

(And note the ':' at the beginning of the line, which stops 'pool' from being included in the interwiki list at the left of the page.)

If you want to output the media-description, stored in the PoolWiki, too, add to the "LocalSettings.php" of the languagewikis:

$wgFetchCommonsDescriptions = true;
$wgSharedUploadDBname = 'pool';  # DB-Name of PoolWiki
$wgSharedUploadDBprefix = 'wiki_'; # Table name prefix for PoolWiki
$wgRepositoryBaseUrl = "";

Gemeinsame Einstellungen

Bei mehrere Wikis sollen wahrscheinlich ähnliche Einstellungen für alle gemeinsam genutzt werden. Hier wird beschrieben, wie das gemacht wird. We recommend that you separate your Extension settings into a different file than your other settings, as detailed below. They can be all put into one large file, but it's not as flexible depending upon your specific needs.

Here is an example directory structure if you do all of the following:

Einstellungen von Erweiterungen
  • Schritt 1
  • Create a file called ExtensionSettings.php with the following contents, and place it in a location similar to the example above.
##### Extension Directory Variables
## These variables allow you to specify a single, shared directory for each grouping of extensions.
## If the directory ever needs to be changed, it can be changed here rather than on every
## item below. DO NOT include a trailing "/".
## Extensions from
# $wgWikimediaExtensions = "/var/www/wikimediaextensions";
## Any third-party extensions
# $wgOtherExtensions = "/var/www/extensions";

### Add globalized extension settings below
#require_once "$wgWikimediaExtensions/ReallyCoolExtension/ReallyCoolExtension.php"; #An example Wikimedia Subversion extension entry

#require_once "$wgOtherExtensions/ReallyCoolExtension/ReallyCoolExtension.php"; #An example third-party extension entry
  • Schritt 2
  • Edit the LocalSettings.php file of each wiki that you want to use the shared settings, and add the following.
require_once "/absolute/path/to/ExtensionSettings.php";
  • Schritt 3
  • Now just add all the references to your various extensions
Einstellungen für Wiki-Familien

These are settings that you want to apply to the entire wiki family. For example, maybe you want to be able to easily put all the wikis into read-only mode at the same time. You can also store the username/password for the database(s), if they are all the same. Additionally, you could control user permissions across your entire wiki from this one file.

If you use a Images/Media commons or pool, we recommend that you do not put these settings in the WikiFamilySettings.php file. That information only applies to every wiki in your wiki family other than your repository. We recommend putting it in a separate file.

Gemeinsam verwendete Databank-Tabellen

See Manual:Shared database for instructions on setting up shared database tables.

Die ultimative minimalistische Lösung

The "ultimate minimalist solution" consists of symlinks;

$ ls -og
lrwxrwxrwx 1 16 2008-11-03 06:29 -> mediawiki
lrwxrwxrwx 1 16 2008-11-03 06:29 -> mediawiki
lrwxrwxrwx 1 16 2008-11-03 06:29 -> mediawiki

Let's see a real example of mediawiki/LocalSettings.php. In real life we must deal with the slight differences in the names and databases of the sites we manage.

if ( !defined( 'MEDIAWIKI' ) ) { 
}    #Protect against web entry
$mysites = array(
    array( '台掃', '', 'radioscanningtw' ),
    array( '蝶園', '',      'transgender' ),
    array( 'ABJ',    '',             'mwabj' )
$mystrings = array( $_SERVER['SCRIPT_FILENAME'] );
if ($wgCommandLineMode) { $mystrings[] = $_SERVER['PWD']; }
$mystrings[] = $IP;
foreach ( $mysites as $site ) {
    foreach ( $mystrings as $string ) {
        if ( strpos( $string, $site[1] ) !== false ) {
            $wgSitename = $site[0];
            putenv( "MW_INSTALL_PATH=/home/jidanni/" . $site[1] );
            $wgDBname = $site[2];
            break 2;
if ( $wgSitename == 'MediaWiki' ){
  trigger_error('Oh no, I still have not set $wgSitename. Somebody tell me. TEL +886-963-114343',E_USER_ERROR);}

## For maintenance scripts, :
if ( $wgServer == 'http://localhost' ) {
    $wgServer = $wgInternalServer = 'http://' . $site[1];
$wgUsePathInfo = false; 
$wgScriptPath = ''; 
$wgDBserver = '';
$wgLogo = "/images/$wgDBname/$wgDBname.png";
switch ( $wgSitename ) {
  #any per-wiki customizations
Note we still individually do database related tasks, e.g., php update.php. (The above code should detect which wiki's update.php you are referring to.) 

Upgrading is simple if you download from Git. (Hopefully there is no more code that assumes there is only one wiki on the disk...)


Unless you do not allow uploads or allow them only for your pool wiki, you will need to create separate image directories and alias them in your vhost configuration:

for i in aaa bbb ccc; do mkdir -p /home/user/images/$i; done, and in's vhost: Alias /w/images /home/user/images/aaa. Same for bbb and ccc.

However you may instead just prefer Manual:Image administration/de , where * just point to the same single directory. Or one could use e.g., *$wgDBname/images/.

Weitere Wikis hinzufügen

To add a wiki to a production Wiki family/de

  1. add its configuration to your web server
  1. temporarily comment out the file_exists("../LocalSettings.php") check of config/index.php and then run it
  1. merge the config/LocalSettings.php produced into LocalSettings.php
  1. add some pages

Alte Wikis entfernen

To remove a wiki from a production Wiki family/de

  1. remove its configuration from
    1. web server
    1. LocalSettings.php


Another option is using the method that the Wikimedia Foundation uses. The rough steps are listed below. This method isn't for the faint of heart, but it has fairly good results, as can be seen by the success the Wikimedia Foundation has had by using this :-)

  1. Configure a template copy of MediaWiki through the online configuration wizard.

    Edit the Main Page if you want a default main page for every wiki you create on your farm.

  2. After that, export your database with mysqldump, phpMyAdmin, etc. This database export can also be structure-only (e.g. mysqldump -uroot -p --no-data dbname > template.sql), in which case you'll have to create the first user with createAndPromote.php.

    Save this on your server in the maintenance/ directory as something like template.sql.

  3. Now, write up a few quick scripts to create a new wiki.

    In summary, you'll need to duplicate the database for a list of wikis (the list can be flat-file based or MySQL/SQLite based). First export the template wiki, then import the template database dump back into the database under the name of each new wiki.

    Use a standard suffix after the new database name (i.e. if the wiki is, then you might choose catwiki as the database name).

  4. In your configuration file, add something like this, fixing the database prefix and your domain as necessary:
    if ( defined( 'MW_DB' ) ) {
        // Command-line mode and maintenance scripts (e.g. update.php) 
        $wgDBname = MW_DB;
    } else {
        // Web server
        $server = $_SERVER['SERVER_NAME'];
        if ( preg_match( '/^(.*)\$/', $server, $matches ) ) {
            $wikiname = $matches[1];
        } else {
            die( "Invalid host name, can't determine wiki name" );
            // Optional: Redirect to a "No such wiki" page.
        if ( $wikiname === "www" ) {
            // Optional: Override database name of your "main" wiki (otherwise "wwwwiki")
            $wikiname = "meta";
        $wgDBname = $wikiname . "wiki";
  5. Configure your DNS with a wildcard A record, and apache with a server alias (like ServerAlias * and you should be in business.

The script maintenance/update.php takes a --wiki parameter that is exported as MW_DB constant. Your LocalSettings.php file needs to set it as the correct $wgDBname. (On the command-line there is no HTTP request, and no "SERVER_NAME":

php maintenance/update.php --wiki catwiki

Your unique LocalSettings.php (which usually consists in a few lines including a CommonSettings.php not directly accessible from the server) uses the $wgDBname variable to initialise the wiki-specific settings. See Manual:$wgConf#Example for how.

You'll also need to fix the upload directories unless you want every wiki to use the same files. As said above, this is probably one of the hardest methods to do, and it requires more technical experience, but it can give really good, clean results.


There are several MediaWiki extensions that attempt to simplify hosting of several wikis by using just one code base, however only one is currently noteworthy:

Siehe auch

  • Central ID — the mechanism by which user accounts can have an extra 'central' identifier.


  1. See this thread concerning the "serialised" folder
  2. In case you are using Composer to install some or all extensions, if supported