Difference between revisions of "XiphInfra:Wiki VM"
Line 120: | Line 120: | ||
If everything works as expected, write a systemd unit or such and start Mathoid with it, for production use. | If everything works as expected, write a systemd unit or such and start Mathoid with it, for production use. | ||
+ | |||
+ | ==== Troubleshooting ==== | ||
Maybe useful for debugging, you can use curl to make a request to Mathoid like this: | Maybe useful for debugging, you can use curl to make a request to Mathoid like this: | ||
− | + | curl -d 'q=E=fobarmc^2' http://127.0.0.1:10042/ | |
+ | |||
+ | If you get errors like <code>spawn java ENOENT</code> make sure you have set | ||
+ | img: false | ||
+ | in your config, as else it will try to use [http://xmlgraphics.apache.org/batik/download.html 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: | ||
+ | |||
+ | <nowiki><syntaxhighlight lang="php"> | ||
+ | $foo = "bar"; | ||
+ | </syntaxhighlight></nowiki> | ||
+ | |||
+ | will display as: | ||
+ | |||
+ | <syntaxhighlight lang="php"> | ||
+ | $foo = "bar"; | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | 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 [http://pygments.org Pygments], so make sure that is installed. That's it. (Phew, much easier compared to Mathoid) |
Revision as of 16:10, 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 and Mathoid
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:
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
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
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.
Troubleshooting
Maybe useful for debugging, you can use curl to make a request to Mathoid like this:
curl -d 'q=E=fobarmc^2' http://127.0.0.1:10042/
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"; </syntaxhighlight>
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)