Intranet/Intranet Installation

TODO:
 * Fix up templates
 * Add media
 * Verify PHP modules required
 * Expand update and backout process
 * Verify the process end to end on a clean install
 * FUTURE - Deploy to Windows, can a similar approach work there (Windows has symlinks of sorts)

This page documents installing Mediawiki from git. The end result is designed to track the production Wikipedia version. After the initial installation we make some simple changes to enhance a base install. Finally the update procedure is described so that you can safely upgrade to a new revision with some confidence that it will still work, with a backout process if something goes wrong

Settings
Either use these settings or choose your own as you follow through the procedure below

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

Alternative webroots
You can put mediawiki wherever you like but if you want to run the web installer, then the initial location must be under the webserver's document root and not referenced via an alias

Pre requisites

 * Web server - Apache 2.4
 * PHP modules: (todo)
 * Database - MariaDB or MySQL
 * Composer is not strictly required but may be handy in the future. Checking out via git will install the extra code the wiki needs because it is already stored in the repository.
 * This command will download and install composer into /usr/local/bin:

Mediawiki
Now find a version using git ls-remote and check it out with git clone

Update the submodules

Optional: Use composer to install additional code - this will actually remove any developer only code, which should be optional for a production wiki. The git version already has the extra code installed

Web based Installer
The installer has to be run from under the web server webroot directly, so be careful here. Run the installer by browsing to http://wiki.example.co.uk/mediawiki and answering the questions. 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. Note that at this point this will not work well in the browser, so don't try testing!

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:

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 Now find a version using git ls-remote and check it out with git clone

Update the submodules

Switch to new code by removing and repointing the symlink

Fix up paths (note that you must use the real path here because symlinks have some surprising behaviours)

Run update.php Now test the new code