XiphInfra:Wiki VM

From XiphWiki
Revision as of 12:08, 23 January 2016 by Martin.leese (talk | contribs) (Add Wiki Account: Typo)
Jump to: navigation, search
Wiki VM
Maintainer(s) ePirat
Host mf4
Service(s) Wiki


As the name suggest, the Wiki VM runs this MediaWiki instance.

It runs an Apache2 server with PHP module, in front of it is a reverse proxy (nginx) running on Catfish. If you need to add or adjust things like headers and the HTTPS redirect, check the nginx config on Catfish, not the Apache2 config.

The current version of MediaWiki and the installed Modules can be found here.

Add Wiki Account

Currently, account creation on the Wiki is disable due to massive spam. Therefore until we find a solution for this, Users are asked to go to the #xiph IRC channel and ask for an account there, which a wiki sysop has to create.

Below is an excerpt from the MediaWiki Page, describing how to create an Account:

  1. Go to Special:UserLogin, when logged in as a sysop.
  2. Click on "Create an account" link to get to the account creation form.
  3. Enter a username and an email address, and click the "by email" button. Note you need $wgEnableEmail=true or else the sysop must pick a password and send it to the user.
  4. The account will be created with a random password which is then emailed to the given address (as with the "forgot password" feature). The user will be requested to change password at first login; when he does this, his e-mail address will also be marked as confirmed.
    When you click the "create account" button instead, you have to manually send the user his password. If you've set $wgMinimalPasswordLength and you've left the password field blank, the user will be emailed an e-mail address confirmation request but will be unable to access Special:Confirmemail to perform the confirmation. Instead, the user will get an error (unless you've added it to $wgWhitelistRead); the user will be able to login with a blank password and then confirm email, but their password will not have been reset (it will have to be reset manually).

Important Modules

These are the most important modules that we have in use:

Math and Mathoid

The Math module allows us to use equations similar as in LaTeX:

<math>E=mc^2</math> will display as E=mc^2

The extension uses Mathoid to render equations, this is how it's configured:

/* Math */
$wgUseTeX           = true;
$wgTexvc            = "$IP/extensions/Math/math/texvc";
$wgMathPath         = "{$wgUploadPath}/math";
$wgMathDirectory    = "{$wgUploadDirectory}/math";
$wgMathMathMLUrl    = "";
$wgMathValidModes   = array(MW_MATH_MATHML, MW_MATH_PNG, MW_MATH_SOURCE);

/* Set Mathoid as default rendering option */
$wgDefaultUserOptions['math'] = MW_MATH_MATHML;

More information about the config can be found on the Math/advancedSettings page.

Once the Math extension is configure, as mentioned, it needs Mathoid to render MathML and SVGs. It's a bit tricky to install therefore below is a short guide how to do so:

Fetch the source code

cd /opt/
git clone https://github.com/wikimedia/mathoid

Install a relatively new node.js version

The packaged version is probably too old, so you should download one from the Node.js download page. For example:

wget https://nodejs.org/dist/v4.2.4/node-v4.2.4-linux-x64.tar.xz
tar xfv ./node-v4.2.4-linux-x64.tar.xz
mv ./node-v4.2.4-linux-x64.tar.xz /opt/node-v4.2.4

Add node binaries to your PATH

echo export PATH=/opt/node-v4.2.4/bin:$PATH >> ~/.bashrc

Install dependencies

Inside the mathoid folder do:

npm install

Change config

Remove the default config symlink and crate one for the prod config:

rm config.yaml
ln -s config.prod.yaml config.yaml

Adjust the config accordingly, currently the config looks similar to:

# Number of worker processes to spawn.
# Set to 0 to run everything in a single process without clustering.
# Use 'ncpu' to run as many workers as there are CPU units
num_workers: ncpu

# Log error messages and gracefully restart a worker if v8 reports that it
# uses more heap (note: not RSS) than this many mb.
worker_heap_limit_mb: 500

# Logger info
  level: warn
  # Use gelf-stream -> logstash
  #- type: gelf
  #  host: logstash1003.eqiad.wmnet
  #  port: 12201

# Statsd metrics reporter
  #type: statsd
  #host: statsd.eqiad.wmnet
  #port: 8125

  - name: mathoid
    module: ./app.js
      port: 10042
      svg: true
      img: false
      texvcinfo: true
      speech: true
      sppechOn: false

Try it

Let's try to start it:

npm start

If it start successfully, go to a Wiki Page, edit it and add a simple equation and preview the page. (Make sure to use a unique equation, as caching could prevent that Mathoid is used, if the equation already exists.)

If everything works as expected, write a systemd unit or such and start Mathoid with it, for production use.


Maybe useful for debugging, you can use curl to make a request to Mathoid like this:

curl -d 'q=E=fobarmc^2'

If you get errors like spawn java ENOENT make sure you have set

img: false

in your config, as else it will try to use Apache™ Batik, which requires Java. I guess not having PNGs is a fair tradeoff, if that saves us from having to use java on the VM.

If there are problems while installing dependencies, make sure your nodejs version is recent enough, try to remove the modules and reinstall them:

rm -rf ./node_modules
npm cache clear
npm install

SyntaxHighlight (GeSHi)

This is used to highlight code blocks:

<syntaxhighlight lang="php">
$foo = "bar";

will display as:

$foo = "bar";

Luckily, this one is much easier to install. It does not, contrary to what the name suggest, depend on GeSHi anymore, but has switched to Pygments, so make sure that is installed. That's it. (Phew, much easier compared to Mathoid)