Manual:Wiki-Familie

This page is a translated version of the page Manual:Wiki family and the translation is 52% complete.
Outdated translations are marked like this.

A wiki family is a collection of two or more wikis that run on the same server and share a common set of resources from the parent installation, while each wiki remains otherwise independent. This setup is an alternative to running fully separate installations of MediaWiki. It may be the preferred choice if the site admin wants to reduce the amount of work involved in managing multiple wikis, or cut down on inode usage. For this reason, some wiki hosting services opt for the wiki family model.

The best known implementation of a wiki family is the wiki farm, although other approaches are possible. A list of known wiki farms is available on WikiApiary .

In diesem Artikel wird gezeigt, wie MediaWiki zu konfigurieren ist, damit mehrere Wikis auf demselben Server laufen können.

Methoden

Wikifarm

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. Das erste Wiki ist wie gewohnt zu installieren. Für Einzelheiten siehe Handbuch:Installationsanleitung .
  2. Der Webserver ist so einzurichten, dass die MediaWiki-Installation für alle Wikis geteilt wird. Für mehrere (Unter-)Domänen können eine Vielzahl von Servernamen aufgelistet werden. Für mehrere Unterverzeichnisse können Rewrite-Regeln, Aliase oder Symlinks verwendet werden. For multiple (sub)domains, have your web server accept connections from all the relevant domains. For multiple subdirectories, you could use rewrite rules, aliases, or symlinks.
  3. Der Code ist oben in LocalSettings.php einzufügen, um das aktuelle Wiki zu erkennen. Note that if the argument to --wiki contains a hyphen, the argument will be split on the hyphen and the resulting two values assigned to MW_DB and MW_PREFIX, respectively. Für Wikis nach Domänennamen:
    $wikis = [
        'example.org' => 'examplewiki',
        'one.example.org' => 'onewiki',
    ];
    if ( defined( 'MW_DB' ) ) {
        // Automatisch von --wiki-Option auf Wartungsskripte setzen
        $wikiID = MW_DB;
    } else {
        // Die MW_DB-Umgebungsvariable verwenden oder den Domänennamen zuordnen
        $wikiID = $_SERVER['MW_DB'] ?? $wikis[ $_SERVER['SERVER_NAME'] ?? '' ] ?? null;
        if ( !$wikiID ) {
            die( 'Unknown wiki.' );
        }
    }
    
    $wgLocalDatabases = $wgConf->wikis = array_values( $wikis );
    $wgDBname = $wikiID;
    $wgDBuser = 'mediawiki';
    
  4. Die Einstellungen sind zu konfigurieren, die für alle Wikis unterschiedlich sein müssen. Zum Beispiel:
    $wgCacheDirectory = "/tmp/mediawiki_cache/$wgDBname";
    $wgUploadDirectory = "$IP/images/$wgDBname";
    $wgUploadPath = "/w/images/$wgDBname";
    
  5. Die Konfiguration erfolgt durch Überschreibungen pro Wiki. Dies sollte mindestens $1 und $2 beeinhalten. This should include at least $wgServer and $wgArticlePath.
    $wgConf->settings = [
        'wgServer' => [
            'examplewiki' => 'https://example.org',
            'onewiki' => 'https://one.example.org',
        ],
        'wgArticlePath' => [
            'default' => '/wiki',
        ],
        'wgSitename' => [
            'default' => 'Example',
            'onewiki' => 'One',
        ],
        'wgLogo' => [
            'default' => '/images/examplewiki/Example_logo.png',
        ],
        'wgLanguageCode' => [
            'default' => 'en',
            'onewiki' => 'pt',
        ],
    ];
    extract( $wgConf->getAll( $wgDBname  ) );
    
    Dies kann auch in einer separaten Datei geschehen, z. B.:
    # LocalSettings.php
    $wgConf->settings = require __DIR__ . '/LocalSettings_overrides.php';
    
    # LocalSettings_overrides.php
    <?php
    return [
        'wgServer' => ..,
        ..,
    ];
    

Um ein neues Wiki zu erstellen, ist zuerst die Datenbank zu erstellen, dann die Einstellungen zu setzen und zuletzt php maintenance/update.php --wiki=mywiki ausführen.

Separate Konfigurationsdateien

Dies ermöglicht es, mehr als ein Wiki auf einem einzigen Server zu installieren und dabei denselben Quellcode-Checkout zu verwenden.

  1. Install the first wiki as normal, via the web or CLI installer, which sets up your database and generates a LocalSettings.php file.
  1. Nach der Installation benennen Sie die generierte Datei LocalSettings.php um, um die Wiki-ID (z. B. Datenbankname) einzuschließen, wie z. B. LocalSettings_mywiki.php.
  2. Die Schritte eins und zwei sind für jedes zu erstellende Wiki zu wiederholen.
  1. Create a new LocalSettings.php file that will load the correct one.

As with the above wiki farm example, a --wiki argument containing a hyphen will be split on the hyphen into two values assigned to MW_DB and MW_PREFIX, respectively.

<?php
$wikis = [
    'example.org' => 'examplewiki',
    'one.example.org' => 'onewiki',
];
if ( defined( 'MW_DB' ) ) {
    // Automatisch von --wiki-Option auf Wartungsskripte setzen
    $wikiID = MW_DB;
} else {
    // Die MW_DB-Umgebungsvariable verwenden oder den Domänennamen zuordnen
    $wikiID = $_SERVER['MW_DB'] ?? $wikis[ $_SERVER['SERVER_NAME'] ?? '' ] ?? null;
}

if ( $wikiID ) {
    require_once "LocalSettings_$wikiID.php";
} else {
    die( 'Unknown wiki.' );
}

// Alle Einstellungen unterhalb dieser Zeile, die für alle Wikis gelten sollen, einfügen
// -------

Befinden sich die Wikis auf der gleichen Domain, aber unter verschiedenen Pfaden (z. B. example.org/wiki1, example.org/wiki2 usw.), kann Folgendes verwendet werden:

<?php
$wikis = [
    '/example' => 'examplewiki',
    '/w_example' => 'examplewiki',
    '/one' => 'onewiki',
    '/w_one' => 'onewiki',
];
if ( defined( 'MW_DB' ) ) {
    // Automatically set from --wiki option to maintenance scripts.
    $wikiID = MW_DB;
} else {
    $path = explode( '/', $_SERVER['REQUEST_URI'] ?? '', 3 )[1] ?? '';
    $wikiID = $_SERVER['MW_DB'] ?? $wikis[ $path ] ?? null;
}

if ( $wikiID ) {
    require_once "LocalSettings_$wikiID.php";
} else {
    die( 'Unknown wiki.' );
}
If you use Short URL, you need to add both your $wgArticlePath and the $wgScriptPath.

Drupal-ähnliche Webseiten

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.
  2. Install MediaWiki and additional tools as usual to a version-declaring subdirectory (e.g., /home/web/mediawiki/mediawiki-1.10.0).
  3. Link the version-declaring directory to a code directory. z.B. ln -s /home/web/mediawiki/mediawiki-1.10.0 /home/web/mediawiki/code
  4. Create a sites directory to contain our images and settings: mkdir /home/web/mediawiki/sites
  5. Das Wiki wie gewohnt aus dem Verzeichnis /code einrichten.
  6. After successful installation, move LocalSettings.php into a sites directory that will be a match when the site is checked. For example, to capture http://example.com/mywiki, one would create the directory example.com.mywiki. z.B. mkdir /home/web/mediawiki/sites/example.com.mywiki. See the Drupal's settings.php file for more information on this.
  7. If you intend to use media files, create an images directory in your site directory. z.B. mkdir /home/web/mediawiki/sites/example.com.wiki/images. Make it writable as necessary.
  8. Place the Drupal-style LocalSettings.php file in your main directory: cp DrupalLocalSettings.php /home/web/mediawiki/code/LocalSettings.php
  9. 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/wiki.example.com/images"; 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. Bei Bedarf sind weitere Änderungen vorzunehmen.
  10. Eine Apache 2-Installation vorbereiten. Beispiel-Seite: wiki.example.com
    1. Create a link to the code directory, if required e.g. ln -s /home/web/mediawiki/code /home/web/wiki.example.com
    2. Create an appropriate virtual host configuration:
      <VirtualHost *:80>
          ServerAdmin me@example.com
          DocumentRoot /home/web/wiki.example.com
          ServerName wiki.example.com
          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/wiki.example.com/images
          # If you want to password protect your site
          #  <Directory /home/web/wiki.example.com>
          #    AuthType Basic
          #    AuthName "My protected wiki"
          #    AuthUserFile /etc/apache2/htpasswd/users-mywiki
          #   require valid-user
          #  </Directory>
      </VirtualHost>
      
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:

How wiki farms are handled in maintenance scripts

MediaWiki-Wartungsskripte (z.B. update.php) akzeptieren ein --wiki-Argument, das als Konstanten MW_DB, MW_PREFIX und MW_WIKI_NAME an die LocalSettings.php -Datei übergeben wird. Der gesamte Wert des --wiki-Arguments ist der Wert von MW_WIKI_NAME.

If there is a dash in the --wiki argument, then the part before the dash is assigned to MW_DB and the part after the dash is assigned to MW_PREFIX.

Diese Tabelle zeigt, wie das funktioniert:

Wie das Argument --wiki ausgewertet wird.
--wiki MW_WIKI_NAME MW_DB MW_PREFIX
enwiki enwiki enwiki empty
enwiki-one enwiki-one enwiki one
enwiki-one-two enwiki-one-two enwiki one-two

Da es für Web-Anfragen kein --wiki-Argument gibt, müssen diese anders behandelt werden. Normalerweise wird der Domänenname und/oder der URL-Pfad zur Auswahl eines Wikis verwendet.

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:

  • en.example.org - Englisch
  • fr.example.org - Französisch
  • de.example.org - Deutsch
  • pool.example.org - Gemeinsam genutzte Medien-Dateien für all diese Wikis.
The above example uses the name "pool". Avoid using the name "commons" because this may conflict with the interwiki link also named commons for Wikimedia Commons.

Also avoid using the name "media" (e.g. media.example.org) as that may cause a conflict between your interwiki and the internal namespace Media: for accessing local media files, e.g. [[media:File.png]].

Gemeinsam verwendete Databank-Tabellen

Consider using a shared database for user accounts. See Handbuch:Gemeinsame Datenbank for instructions on setting up shared database tables.

Interwiki

Die Interwikilinks zwischen allen Wikis setzen, indem man Erweiterung:Interwiki nutzt. If the wikis are language editions, it is recommended to name the interwiki prefix after the exact language code. For example, "de" for the German wiki in your family. This way, you can connect pages about the same subject using language links.

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

If you have a central wiki for files, create a prefix for this as well. E.g. pool to https://pool.example.org/wiki/$1 and enable the "Forward" checkbox to recognise it as a local wiki in the same family.

Hochladen

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 = "https://pool.example.org/index.php/Special:Upload";

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

$wgUploadMissingFileUrl= "https://pool.example.org/index.php/Special:Upload";

Wenn Uploads nur für das Pool-Wiki zugelassen werden sollen, kann Folgendes verwendet werden:

if ( $wgDBname === 'pool' ) {
	$wgEnableUploads = true;
} else {
	$wgEnableUploads = false;
}

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 = 'https://pool.example.org/images';
$wgSharedUploadDirectory = '/(LOCALPATH)/POOL-FOLDER/images/';
$wgHashedSharedUploadDirectory = true;

Nun kann Pools mit Dateien (z.B. [[File:MyLogo.png]]) in die Sprachwikis integriert werden.

Bildbeschreibung

In jedem Sprachwiki ist (als Administrator) die Nachricht MediaWiki:Sharedupload-desc-here zu öffnen.

Der Text ist zu ändern in etwas wie:

Diese Datei wird im data-pool gespeichert.
Für Informationen und Beschreibungen siehe die [[:pool:File:{{PAGENAME}}|Beschreibung hier]].

(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 = "https://pool.example.org/index.php/Image:";

Wiki-Familien-Erweiterungen

Es gibt mehrere MediaWiki-Erweiterungen, die versuchen, das Hosting mehrerer Wikis durch die Verwendung einer einzigen Code-Basis zu vereinfachen, allerdings ist derzeit nur eine davon nennenswert:

Siehe auch