Intranet/Intranet Installation

This page documents installing MediaWiki, some basic customisation and an upgrade process. This process builds upon Intranet Reference Build Ubuntu

In this article, locally maintained extensions are those that I have downloaded or checked out with git and loaded into MediaWiki myself. This is the code that I store under local-extensions in this article. The majority of extensions that I use are those that are included with the MediaWiki software itself.
 * Install from Git
 * Use symlinks to keep code and data separate
 * Database backup method
 * Simple, safe upgrades
 * Auto created users matching web server authentication scheme
 * Visual Editor

Settings
This table shows the settings I have chosen. You can pick your own but make sure you are consistent!

Filesystem layout
The directory structure you end up with is outlined in the following table. We use symlinks to switch between versions whilst keeping the webserver configuration constant:

Pre requisites

 * Install PHP modules
 * Install git
 * Imagemagick (for image thumbnails)
 * Setup database. Set a suitable password (line 4 below) 'random_string '.  The password will be put in the LocalSettings.php that will be generated later in this process but keep a note of it.

Install MediaWiki software
To help you decide what version to run, check the official release status, check what version Wikipedia is using look at change logs for development status

MediaWiki software

 * Find a version using git ls-remote:
 * Clone the chosen version
 * Update the submodules and Composer managed libraries

Web based Installer

 * This is just the initial install. We will change the URL to access MW later.
 * Browse to https://wiki.example.co.uk/mediawiki and the first run wizard will start. Keep the settings to a minimum and do not enable any modules. At the end, download the provided file and upload it to the web server's filesystem at /var/www/html.   Create the symlink to it from the wiki folder.
 * Disable the Minerva Neue skin in LocalSettings.php to get the wiki to load until it is no longer dependent on MobileFrontend . Edit LocalSettings.php and towards the end put a # in front of wfLoadSkin( 'MinervaNeue' );

Short URLs

 * Add two Alias statements outside of the virtual host definition. These are the final short URLs:
 * Change $wgScriptPath and add $wgArticlePath in LocalSettings.php to match the short URL:
 * Browse to https://wiki.example.co.uk and check https://wiki.example.co.uk/wiki/Special:Version to make sure it all looks OK.

Logo

 * Copy a logo file into /var/www/html and rename it to logo.gif (or.png or whatever) and reference it in LocalSettings.php

Cache

 * This enables a simple filesystem based cache which will help speed up page load times. Create a cache directory for the wiki to use:
 * Add this to LocalSettings.php:

Cronjob for runJobs

 * Add the following to LocalSettings.php to disable runjobs
 * Add this to crontab (change the timings to suit - this example runs every seven minutes)
 * Create a directory for the log
 * When you are happy that runJobs is working correctly then either use something like logrotate to handle the ever growing log file or disable it by removing the redirection in crontab.

Enable wikieditor

 * Edit LocalSettings.php and add this at the bottom:
 * Try editing a page. if the editor does not appear then hold down shift and press the reload button in your browser to clear the cached page.

Auth_remoteuser
The reference build that this article is part of sets REMOTE_USER via Kerberos.
 * Create local-extensions area. This avoids our locally maintained extensions from being overwritten by upgrades
 * Get the latest code
 * Enable and configure the extension. This extension appears to break CirrusSearch and isn't needed when running maintenance scripts, so it is conditionally disabled.  Setting $wgExtensionDirectory and then resetting it back to default enables the wfLoadExtension call to work.
 * You should now be logged into an automatically created wiki account based on your AD username when you access the wiki.

Visual Editor
The Visual Editor extension. PHP-Curl is required for VE to work at all. Installing curl itself is optional but useful for testing from the local command line. Enable the Extension and Parsoid by adding these lines towards the bottom of LocalSettings.php but before the auth_remoteuser configuration. Add AllowEncodedSlashes to the Apache virtualhost configuration and reload Apache. This enables editing of subpages: Visual Editor will make a connection from the system's IP address and not its loopback address to the REST API ie /w/api.php. If authentication is in use in a  block as is documented here, then this will cause a 401 error when trying to edit. Add the additional RequireAll block, replacing 10.10.10.10 with the real IP address of the system, this will allow that IP address to connect without authentication: This is not a very elegant solution and I will look for a better one Gerdesj (talk) 11:00, 21 May 2021 (UTC)

Database Backups

 * This script is really designed for ad hoc use because you will be backing up the entire system anyway
 * Create backup script in /usr/local/bin/mediawiki-backup.sh
 * Make the script executable
 * Run it and verify that you have a database backup file. There should be a file named wiki- .sql - check its contents to verify that it really is a backup

Updating
It is possible to avoid the downtime associated with snapshots and waiting for the code to download but this process is designed to be as safe as possible.

Before updating

 * Perform pre-upgrade change control process
 * Check backups
 * Shutdown the system and take a snapshot
 * Start the system

Update the code

 * Do the MediaWiki installation section of this article to get the new code, for example:


 * Stop the web server (systemctl stop apache2)


 * Create symlinks

Switch to the new code

 * Make the wiki read-only. Put this at the bottom of LocalSettings.php:
 * Start Apache (systemctl start apache2)
 * Remove and re-point the symlink.
 * Make the wiki read/write. Delete or comment out $wgReadOnly in LocalSettings.php


 * Update local extensions. In general, cd into each directory and run git pull

Sometimes you will get an error when running update.php that points to one or more lines in LocalSettings.php. If that line relates to module loading with the old style, then try converting it to the newer wfLoadExtension; format.
 * Run update.php


 * Test the new code
 * Notify users that the wiki is available again
 * Perform post-upgrade change control process