User:Mainframe98/Wiki Family
This page is a work in progress It may contain content out of date, content that is wrong or missing its content in general. |
Manual:Wiki family is quite confusing, and most likely out of date. That it is possible is proven by the many farms out here, some even using configurations similar to Wikimedia. It is my attempt to make things worse create (yet another) guide on creating a Wiki family. This example is based on the approach by Wikimedia. Why? For the glory of MediaWiki of course Because it is the most interesting way, and as mentioned in Manual:Wiki family "...it can give really good, clean results."
Disclaimer: I don't know what I'm doing. I'm woefully inexperienced with Unix-like operating systems and probably shouldn't touch them without a 10-foot pole. You are advised to be cautious and verify before following any steps below.
Used Environment
editRaspbian Jessie LightDebian- PHP default package (7.0)
- MariaDB
- Apache2
Installation
editI have a GitHub repository where an installer that uses this configuration is kept.
Configuration
editConfiguration Template
editI have a GitHub repository where an example configuration is kept. You can use this as a template.
CommonSettings.php
editThis file contains all the shared wiki settings. General groups that every wiki should have (such as a rollback group), things like an emergency email address etc. Here, you can also add a listing for extensions, such as the example below. Additionally, you may include the extension listings in a separate file, such as LocalExtensions.php, or equivalent.
Example
edit#Extensions enabled on all wikis
wfLoadExtensions( 'CentralAuth' );
if ( $wgUseMediaWikiChat ) {
wfLoadExtensions( 'MediaWikiChat' );
}
InitialiseSettings.php
editHere, the $wgConf
gets created and filled. See that page for information on how to use that setting.
Example
edit$wgConf = new SiteConfiguration();
$wgConf->settings = [
'wgSETTINGNAMEHERE' => [
'default' => false, # Default
'wikipedia'=> true, # Suffix group with Wikipedia's
'metawiki' => true # Metawiki
];
LocalSettings.php
editYou'll need several modifications to LocalSettings.php:
Database name determiner
editThis part figures out which database to obtain. This becomes important later on when $wgConf needs a database name to get the site specific settings.
Code
edit// Generate the db name
if ( defined( 'MW_DB' ) ) {
// Command-line mode and maintenance scripts (e.g. update.php)
$wgDBname = MW_DB;
} else {
// Web server
$server = $_SERVER['SERVER_NAME'];
$urlComponents = explode( '.', $server );
if ( !$urlComponents ) {
die( "Invalid host name, can't determine wiki name" );
// Optional: Redirect to a "No such wiki" page.
}
// Reverse the array so the tld is the first item in the array
$urlComponents = array_reverse( $urlComponents );
// If no sub domain has been given, set it to www as default
if ( count( $urlComponents ) < 3 ) {
$urlComponents[2] = 'www';
}
// Determine wiki name and remove any periods from the name
$wikiname = implode( '', array_slice( $urlComponents, 2 ) );
// Optional: Override database name of your "main" wiki (otherwise "wwwwiki")
if ( $urlComponents[2] === "www" ) {
$wikiname = "meta";
}
// Determine the database name postfix by checking the domain name
switch ( $urlComponents[1] ) {
default:
$postfix = 'wiki';
break;
}
$wgDBname = $wikiname . $postfix;
}
Notes
edit- This configuration supports multiple domains and setting a different database postfix for each domain. Example; enwiki for en.wikipedia.org, but enwiktionary for en.wiktionary.org
Loading local databases
editThere are multiple ways to do this. In this example, the list of available databases (all known databases to the wiki family, closed or not) is loaded from a database list, all.dblist. In most cases, this file also contains the language of the wiki and the name of the wiki.
Code
edit$fgDatabaseList = file( 'all.dblist' );
# Set the language and site name for each database/wiki
foreach ( $fgDatabaseList as $wiki ) {
$wikiDB = explode( '|', $wiki, 3 );
list( $dbName, $siteName, $siteLang ) = array_pad( $wikiDB, 3, '' );
$wgLocalDatabases[] = $dbName;
$wgConf->settings['wgSitename'][$dbName] = $siteName;
$wgConf->settings['wgLanguageCode'][$dbName] = $siteLang;
}
all.dblist example
editmetawiki|Meta Wiki|en enwiki|English Wiki|en nlwiki|Nederlandse Wiki|nl
Other things to do
editConfiguring MediaWiki is one step, but to successfully setup a wiki family, you also need to configure the environment to work like intended.
DNS
editBasically, there are two things you can do:
- Shell out the money and grab yourself a fancy domain name with unlimited subdomains and point this to your web server.
- Setup a personal DNS server, dnsmasq for example, and have it redirect all requests to your requested domain to your web server. This will only work if your device(s) are configured to use your web server as a DNS server. This is great for testing and keeping your domain private for the time being.
Other notes
editTry to keep this organized.
A tag is a label that can be applied to a wiki. It is also referred to as a set. A tag represents a group with a specific property, such as having an extension installed. This is not mentioned in the documentation or in the comments of siteConfiguration.php though... Usually, a tag is applied by placing the name of the database in a specific database list. Basically, anything in $wgConf is a set, with database names being a set consisting only of that wiki, and default being the only exception.
Further reading
editDocumentation
editWikimedia deployment specific
editMediaWiki.org
editBundled MediaWiki documentation
editActual examples
edit- Miraheze's Github Repository - A setup incredibly similar to the one used by Wikimedia, running the latest stable version with CentralAuth. Production configuration is available in their mw-config repository
Wikimedia
edit- Wikimedia's CommonSettings.php
- Wikimedia's InitialiseSettings.php
- Wikimedia's wgConf.php
- MediaWiki-Configuration Repo (Github mirror)