Mediawiki
Installation
This assumes Ubuntu 14.04 LTS, Mediawiki version ≥ 1.24 and a passing familiarity with Git. First, some prerequisites:
apt-get install git apache2 libapache2-mod-php5 php5-curl php5-mysql curl
Now clone the core code into the target directory:
git clone http://gerrit.wikimedia.org/r/p/mediawiki/core.git mediawiki
Next, we need to pull in the dependencies with PHP composer. First install composer:
curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer
Then use it to pull dependencies into MediaWiki:
cd mediawiki composer install
Managing skins and extensions
MediaWiki has two directories for these: skins and extensions. There are several ways to manage them, listed here with increasing complexity:
- manually download the skins and extensions you need from the Mediawiki Skin and Extension Distributor pages and unzip them into the codebase,
- manage each skin and extension using a git clone in the appropriate place in the codebase, or
- manage the git repositories of all skins and extensions externally, and use git submodule update to fetch the ones you need, and create symbolic links to the directories in the codebase to enable them.
Let's do things the hard way. Clone the extensions and skins root repositories, and set up the git submodules:
git clone https://gerrit.wikimedia.org/r/mediawiki/skins skins-available cd skins-available git submodule init cd .. git clone https://gerrit.wikimedia.org/r/mediawiki/extensions extensions-available cd extensions-available git submodule init cd ..
You'll need the Vector skin right off the bat:
cd skins-available git submodule update --recursive Vector cd ../mediawiki/skins ln -s ../../skins-available/Vector
Now when we want an extension, say the Cite extension, we can:
cd extensions-available git submodule update --recursive Cite cd ../mediawiki/extensions ln -s ../../extensions-available/Cite
You should now be able to point Apache or nginx at the mediawiki directory and install it using the browser (you may need to set up a MySQL database and/or user).
Visual Editor
Install Parsoid
Parsoid is a small Node.js REST service that parses between MediaWiki syntax and HTML DOM. A stable version will be released to OS package maintainers in late 2015, but in the meantime add the development apt repository:
apt-key advanced --keyserver keys.gnupg.net --recv-keys 5C927F7C echo 'deb [arch=amd64] http://parsoid.wmflabs.org:8080/deb wmf-production main' > /etc/apt/sources.list.d/parsoid.list apt-get update
Then install and configure Parsoid:
apt-get install parsoid vi /etc/mediawiki/parsoid/settings.js # change URL to point to installed api.php
Install the required MediaWiki extensions
Install Visual Editor and its two dependent extensions (Parsoid and UniversalLanguageSelector) into the Mediawiki extensions directory:
cd extensions-available git submodule update --recursive VisualEditor Parsoid UniversalLanguageSelector cd ../mediawiki/extensions ln -s ../../extensions-available/VisualEditor ln -s ../../extensions-available/Parsoid ln -s ../../extensions-available/UniversalLanguageSelector
Then edit LocalSettings.php and add this at the bottom:
require_once "$IP/extensions/Parsoid/Parsoid.php"; require_once "$IP/extensions/UniversalLanguageSelector/UniversalLanguageSelector.php"; require_once "$IP/extensions/VisualEditor/VisualEditor.php"; $wgVisualEditorParsoidURL = 'http://localhost:8142'; $wgVisualEditorParsoidPrefix = 'localhost'; $wgDefaultUserOptions['visualeditor-enable'] = 1;
Caching
PHP opcache
Like any PHP application, use the opcache. If your PHP version is < 5.5 install php5-xcache, otherwise enable the built-in opcache by adding this in php.ini:
[opcache] opcache.enable=1 opcache.enable_cli=1 opcache.memory_consumption=128 opcache.interned_strings_buffer=8 opcache.max_accelerated_files=4000 opcache.use_cwd=1 opcache.validate_timestamps=1 opcache.revalidate_freq=0 opcache.fast_shutdown=0
MediaWiki file cache
Use the file cache, Luke. It's simple but effective. In LocalSettings.php:
$wgUseFileCache = true; $wgFileCacheDirectory = "/var/cache/mediawiki"; $wgShowIPinHeader = false;
And create the appropriate cache directory:
sudo mkdir -p /var/cache/mediawiki sudo chown www-data:www-data /var/cache/mediawiki