Difference between revisions of "Mediawiki"

From Jon's Wiki
Line 34: Line 34:
 
== Visual Editor ==
 
== Visual Editor ==
  
Install the [https://www.mediawiki.org/wiki/Parsoid/Setup Parsoid] service:
+
=== Install Parsoid ===
 +
 
 +
[https://www.mediawiki.org/wiki/Parsoid/Setup 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
 
  apt-key advanced --keyserver keys.gnupg.net --recv-keys 5C927F7C
 
  <nowiki>echo 'deb [arch=amd64] http://parsoid.wmflabs.org:8080/deb wmf-production main' > /etc/apt/sources.list.d/parsoid.list </nowiki>
 
  <nowiki>echo 'deb [arch=amd64] http://parsoid.wmflabs.org:8080/deb wmf-production main' > /etc/apt/sources.list.d/parsoid.list </nowiki>
  apt-get update && apt-get install parsoid
+
  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''
 
  vi /etc/mediawiki/parsoid/settings.js  ''# change URL to point to installed api.php''
  
TODO: more stuff.
+
=== Install the required MediaWiki extensions ===
 +
 
 +
Install Visual Editor and its two dependent extensions (Parsoid and UniversalLanguageSelector) into the Mediawiki <tt>extensions</tt> 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 <tt>LocalSettings.php</tt> 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";
 +
 +
<nowiki>$wgVisualEditorParsoidURL = 'http://localhost:8142';</nowiki>
 +
$wgVisualEditorParsoidPrefix = 'localhost';
 +
$wgDefaultUserOptions['visualeditor-enable'] = 1;
  
 
== Caching ==
 
== Caching ==

Revision as of 02:11, 14 July 2015

Installation

This assumes Ubuntu 14.04 LTS, Mediawiki version ≥ 1.24 and a passing familiarity with Git. First, clone the core code into the target directory:

git clone http://gerrit.wikimedia.org/r/p/mediawiki/core.git mediawiki

Clone the extensions and skins. These are tracked in hundreds of separate git repositories (here, we clone the root and use git submodules to manage them):

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 ..

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

Next, we need to pull in the dependencies with PHP composer.

composer install

TODO: tbc... catchy-bussy


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