Intranet/Intranet Installation

TODO:
 * Add media
 * Expand update and backout process
 * Move prereqs to another page



Introduction
This page documents installing Mediawiki from git and an upgrade process.

Filesystem layout
By following this procedure, the directory structure you end up with is like this:

Pre requisites

 * Web server - Apache 2.4
 * PHP modules
 * php-mbstring
 * php-xml
 * php-mysqli
 * php-apcu
 * php-intl
 * Database - MariaDB
 * Create the database first eg "mediawiki" with a specific user and password for access
 * git
 * imagemagick (for image thumbnails) See https://www.mediawiki.org/wiki/Manual:Installing_third-party_tools

Mediawiki
cd /var/www/html Now find a version using git ls-remote and check it out with git clone git ls-remote --heads https://gerrit.wikimedia.org/r/p/mediawiki/core|2 = git clone --depth=1 --single-branch --branch wmf/1.27.0-wmf.1 https://gerrit.wikimedia.org/r/p/mediawiki/core.git wmf/1.27-wmf.1 Update the submodules cd wmf/1.27-wmf.1 && git submodule update --init --recursive

Web based Installer
The installer has to be run from under the web server webroot directly. Browse to https://doc.example.co.uk/wiki If you are missing any php modules then install them to continue. Most of these should be covered by the pre-requisites above. Keep the settings to a minimum and don't enable any modules. All of this can be changed later. At the end, download the provided LocalSettings.php file and upload it to the web server's filesystem at /var/www/html. Finally symlink to it from the wiki folder. cd /var/www/html/wiki ln -s /var/www/html/LocalSettings.php

Fixup other paths
cd /var/www/html/wiki rm -Rvf images ln -s /var/www/html/images

Short URLs
Add a couple of Aliases to the virtual host definition and restart/reload the web server daemon. These are for the final desired short URLs:

 ...         DocumentRoot /var/www/html Alias /wiki /var/www/html/wiki/index.php Alias /w   /var/www/html/wiki ... 

Change $wgScriptPath and $wgArticlePath in LocalSettings.php to match the short URL: ... $wgScriptPath = "/w"; $wgArticlePath = '/wiki/$1'; ...

Logo
Copy a logo file into /var/www/ and symlink it to logo.gif (or.png or whatever) and reference it in LocalSettings.php $wgLogo = "/logo.gif";

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: mkdir /var/cache/mediawiki chown apache:apache /var/cache/mediawiki

Add this to LocalSettings.php: $wgCacheDirectory= "/var/cache/mediawiki";

Cronjob for update.php
Add the following to LocalSettings.php to disable runjobs $wgJobRunRate = 0;
 * 1) Run jobs via cron

Add this to crontab 2-59/17 * * * * /usr/bin/php /var/www//wiki/maintenance/runJobs.php > /var/log/runJobs.log 2>&1

Check and test base installation and tidy up
Browse to http://wiki.example.co.uk/wiki and verify a page similar to this:

Browse to http://wiki.example.co.uk/wiki/Special:version and verify the version for the wiki - it should match the branch chosen above, also verify the short URLs are displayed correctly in the Entry Point URLs table:

Try and create a new page and perform other tests to make sure that base functionality is working correctly. Try to fix any errors now rather than carrying on and making problems more complex to diagnose and fix.

Updating
By maintaining the link to the code via a symlink and using more to ensure that we don't lose images and settings by accident we can switch versions quickly $ cd /var/www Now find a version using git ls-remote and check it out with git clone git ls-remote --heads https://gerrit.wikimedia.org/r/p/mediawiki/core git clone --depth=1 --single-branch --branch wmf/1.27.0-wmf.4 https://gerrit.wikimedia.org/r/p/mediawiki/core.git wmf/ 1.27-wmf.4 Update the submodules cd wmf/1.27-wmf.4 git submodule update --init --recursive Fix up paths (note that you must use the real path here because symlinks can have some surprising behaviour). You will have to remove the images directory first if it already exists. ln -s ../../logo.gif rm -rvf images ln -s ../../images|4=ln -s ../../LocalSettings.php Switch to new code by removing and re-pointing the symlink. If this wiki is running on a virtual machine, now is a good time to snapshot it. cd /var/www rm wiki ln -s wmf/1.27-wmf.4 wiki Run update.php /usr/bin/php /var/www/wiki/maintenance/update.php Now test the new code