Difference between revisions of "XiphInfra:Wiki VM"
(→Math) |
|||
Line 21: | Line 21: | ||
The [https://www.mediawiki.org/wiki/Extension:Math Math] module allows us to use equations similar as in LaTeX: | The [https://www.mediawiki.org/wiki/Extension:Math Math] module allows us to use equations similar as in LaTeX: | ||
− | <math>E=mc^2</math> | + | <code><nowiki><math>E=mc^2</math></nowiki></code> will display as <math>E=mc^2</math> |
+ | |||
+ | The extension uses Mathoid to render equations, this is how it's configured: | ||
+ | |||
+ | <syntaxhighlight lang="php"> | ||
+ | /* Math */ | ||
+ | $wgUseTeX = true; | ||
+ | $wgTexvc = "$IP/extensions/Math/math/texvc"; | ||
+ | $wgMathPath = "{$wgUploadPath}/math"; | ||
+ | $wgMathDirectory = "{$wgUploadDirectory}/math"; | ||
+ | $wgMathMathMLUrl = "http://127.0.0.1:10042"; | ||
+ | $wgMathValidModes = array(MW_MATH_MATHML, MW_MATH_PNG, MW_MATH_SOURCE); | ||
+ | |||
+ | /* Set Mathoid as default rendering option */ | ||
+ | $wgDefaultUserOptions['math'] = MW_MATH_MATHML; | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | More information about the config can be found on the [https://www.mediawiki.org/wiki/Extension:Math/advancedSettings 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: | ||
+ | |||
+ | ==== 1. Fetch the source code ==== | ||
+ | |||
+ | cd /opt/ | ||
+ | git clone https://github.com/wikimedia/mathoid | ||
+ | |||
+ | ==== 2. Install a relatively new node.js version ==== | ||
+ | The packaged version is probably too old, so you should download one from the [https://nodejs.org/en/download/ 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 | ||
+ | |||
+ | ==== 3. Add node binaries to your PATH ==== | ||
+ | |||
+ | echo export PATH=/opt/node-v4.2.4/bin:$PATH >> ~/.bashrc | ||
+ | |||
+ | ==== 4. Install dependencies ==== | ||
+ | Inside the mathoid folder do: | ||
+ | |||
+ | npm install | ||
+ | |||
+ | ==== 5. 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: | ||
+ | |||
+ | <syntaxhighlight lang="yaml"> | ||
+ | # 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 | ||
+ | logging: | ||
+ | level: warn | ||
+ | streams: | ||
+ | # Use gelf-stream -> logstash | ||
+ | #- type: gelf | ||
+ | # host: logstash1003.eqiad.wmnet | ||
+ | # port: 12201 | ||
+ | |||
+ | # Statsd metrics reporter | ||
+ | metrics: | ||
+ | #type: statsd | ||
+ | #host: statsd.eqiad.wmnet | ||
+ | #port: 8125 | ||
+ | |||
+ | services: | ||
+ | - name: mathoid | ||
+ | module: ./app.js | ||
+ | conf: | ||
+ | interface: 127.0.0.1 | ||
+ | port: 10042 | ||
+ | svg: true | ||
+ | img: false | ||
+ | texvcinfo: true | ||
+ | speech: true | ||
+ | sppechOn: false | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | ==== 6. 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. |
Revision as of 15:54, 20 January 2016
Wiki VM | |
---|---|
Maintainer(s) | ePirat |
Host | mf4 |
IPs | 192.168.2.180 |
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.
Important Modules
These are the most important modules that we have in use:
Math
The Math module allows us to use equations similar as in LaTeX:
<math>E=mc^2</math>
will display as
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 = "http://127.0.0.1:10042";
$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:
1. Fetch the source code
cd /opt/ git clone https://github.com/wikimedia/mathoid
2. 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
3. Add node binaries to your PATH
echo export PATH=/opt/node-v4.2.4/bin:$PATH >> ~/.bashrc
4. Install dependencies
Inside the mathoid folder do:
npm install
5. 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
logging:
level: warn
streams:
# Use gelf-stream -> logstash
#- type: gelf
# host: logstash1003.eqiad.wmnet
# port: 12201
# Statsd metrics reporter
metrics:
#type: statsd
#host: statsd.eqiad.wmnet
#port: 8125
services:
- name: mathoid
module: ./app.js
conf:
interface: 127.0.0.1
port: 10042
svg: true
img: false
texvcinfo: true
speech: true
sppechOn: false
6. 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.