From WebarchDocs
Jump to: navigation, search

MediaWiki notes for sites running on Webarchitects servers.


The notes for a manual install follow, see our Ansible playbooks for automating most of the install.

Install the MediaWiki code in ~/sites/default/w/ (you will need to create this directory) and then set these variables in LocalSettings.php:

$wgScriptPath = "/w"; 
$wgArticlePath = "/wiki/$1";  

Edit your ~/sites/default/.htaccess file:

<IfModule mod_rewrite.c>
  # Enable the rewrite engine
  RewriteEngine On
  # Short url for wiki pages
  RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]
  # Redirect / to Main Page
  RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]

The above will result in URL's like this: and this is the recomended way to set it up.

If however you want to have (please note that this not recomended), then install the MediaWiki code in ~/sites/default/ and then set these variables in LocalSettings.php:

$wgScriptPath = "";
$wgArticlePath = "/$1";

Edit your ~/sites/default/.htaccess file:

<IfModule mod_rewrite.c>
  # Enable the rewrite engine
  RewriteEngine On
  # If the request isn't for a file
  RewriteCond %{REQUEST_FILENAME} !-f
  # If the request isn't for a directory
  RewriteCond %{REQUEST_FILENAME} !-d
  # Then send the request to index.php with the PATH_INFO
  RewriteRule ^(.*) index.php?title=$1 [L,QSA]

Note that you will need to edit the w/images/.htaccess file to comment this line out:

#Options +FollowSymLinks

As the Webarchitects servers don't allow clients to set Apache Options in .htaccess files, without this change uploaded files cannot be served without generating errors.


If you have a HTTPS certificate you can add this to LocalSettings.php:

$wgSecureLogin = true;

Also make sure you don't have the protocol set to http:// for the $wgServer, for example, set it to be agnostic:

## The protocol and server name to use in fully-qualified URLs
$wgServer = "//";

Or better set it to use HTTPS:

## The protocol and server name to use in fully-qualified URLs
$wgServer = "";

And add this to your ~/sites/default/.htaccess file:

# STS Header
Header set Strict-Transport-Security "max-age=31536000" env=HTTPS

If you do the above things then people using a modern web browser, who login, will only access the site via encrypted connections.


We have a Parsiod server available for use by client sites, you will need to contact us to ask for this to be made available for your site. Following are the steps you will need to follow to use it.

Install the VisualEditor extension and add these settings to your LocalSettings.php, note that you will need to change to the domain name of your MediaWiki site:

require_once "$IP/extensions/VisualEditor/VisualEditor.php";

// Enable by default for everybody
$wgDefaultUserOptions['visualeditor-enable'] = 1;

// Don't allow users to disable it
$wgHiddenPrefs[] = 'visualeditor-enable';

// OPTIONAL: Enable VisualEditor's experimental code features
#$wgDefaultUserOptions['visualeditor-enable-experimental'] = 1;

// URL to the Parsoid instance
// MUST NOT end in a slash due to Parsoid bug
// Use port 8142 if you use the Debian package
$wgVisualEditorParsoidURL = '';

// Interwiki prefix to pass to the Parsoid instance
// Parsoid will be called as $url/$prefix/$pagename
//$wgVisualEditorParsoidPrefix = '';
$wgVirtualRestConfig['modules']['parsoid'] = array(
  'url' => '',
  'domain' => '',
  'prefix' => ''

If you are running MediaWiki 23.x or older you will need to install the Parsoid extension and add the following to LocalSettings.php:

require_once "$IP/extensions/Parsoid/Parsoid.php";

HTTP Authentication

If your MediaWiki site is using HTTP Authentication and HTTPS then the Parsoid server isn't going to be able to connect to the API of the wiki, so you need to edit the ~/.sites/default/htaccess file to allow the IP address of the Parsiod to have unauthenticated access, for example:

AuthUserFile /home/example/private/.htpasswd
AuthType Basic
AuthName "My Private Wiki"
require valid-user
# for Parsoid server
Order deny,allow
Deny from all
Allow from 
Satisfy any

Parsoid Server Settings

Before the VisualEditor will work your domain will need adding to the /etc/mediawiki/parsoid/config.yaml file on the Parsoid server, please contact us at to ask for this to be done, for example (note that spaces not tabs are needed for the whitespace):

        - #
          uri: ''
          domain: ''

After making the changes the service will need restarting, service parsoid restart, in addition the IP address of the server might need adding to /etc/iptables/rules.v4, for example:

 -A INPUT -p tcp --dport 8142 -s -j ACCEPT


If you want to use our Piwik server then install the Piwik extension and ask for your site to be added to the Piwik server and get the site id and then add the following to LocalSettings.php, where XX is your site ID:

// Piwik
require_once "$IP/extensions/Piwik/Piwik.php";
$wgPiwikURL = "";
$wgPiwikIDSite = "XX";


Some notes on common customisations for MediaWiki.


To add "Hosted by Webarchitects" to the footer and for it to link to a Webarchitects page on the wiki add the following to LocalSettings.php:

// MediaWiki:Footerpage should contain the name of the page to link to, eg "Webarchitects"
// MediaWiki:Footertext should contain the text to be hyperlinked, eg "Hosted by Webarchitects"
$wgHooks['SkinTemplateOutputPageBeforeExec'][] = 'lfFooterLink';
function lfFooterLink( $sk, &$tpl ) {
    $tpl->set( 'footertext', $sk->footerLink( 'footertext', 'footerpage' ) );
    $tpl->data['footerlinks']['places'][] = 'footertext';
    return true;

And create MediaWiki:Webarchitectspage‎‎ with the name of the page to link to, in this case Webarchitects and a MediaWiki:Webarchitects page with "Hosted by Webarchitects" in it.

Mobile Phone Support

Install Extension:MobileFrontend for a better experience on mobile devices.


To enable additional file types to be uploaded add this to the LocalSettings.php file:

# Add several file types to the default array
$wgFileExtensions = array_merge(
    $wgFileExtensions, array(
            'svg', 'ppt', 'pdf', 'psd', 'mp3', 'xls', 'xlsx', 'swf', 'doc',
            'docx', 'odt', 'odc', 'odp', 'odg', 'mpp'

Enable Large Thumbnails

The default is quite low, add this to the LocalSettings.php file:

$wgMaxImageArea = "100000000";


See MediaWiki Sidebar and create MediaWiki:Sidebar to add / remove items from the side navigation bar.

SVG Thumbnails

The permissions needed by the MediaWiki extensions for thumbnailing SVG graphics (for example creating symlinks) are not allowed by the Webarchitects Shared Hosting servers, so the best option is to install and use the NativeSvgHandler extension, download and extract it to the extensions directory and then add the followig to the LocalSettings.php file:

require_once "$IP/extensions/NativeSvgHandler/NativeSvgHandler.php";
$wgAllowTitlesInSVG = true;

Hide history

If you want to make some content which was posted in error unavailable in the history of a page (for example some personal details) then enable the RevisionDelete functionality by adding this to LocalSettings.php:

$wgGroupPermissions['sysop']['deletelogentry'] = true;
$wgGroupPermissions['sysop']['deleterevision'] = true;

And then sysops have more options via the View History page.