Show Advanced KnowledgeHide Advanced KnowledgeMathjax
Install Mathjax server
I recommend to run an own mathjax server if you plan to use this service, because this will be the quickest way to run mathjax. The first step is to install node, but be already installed it in the chatserver section above. So we just need to install some npm packages and create a start script.
Node versions < 5 will not work with mathjax. Please update to 6.9.5 or similar like described in the chat section above.
mkdir /opt/mathjaxcd /opt/mathjaxnpm install https://github.com/mathjax/MathJax-node/tarball/masternpm install https://github.com/tiarno/mathjax-server/tarball/mastercd node_modulesln -s mathjax-node MathJax-nodemkdir mathjax-node/batikcd mathjax-node/batik- You can also choose a higher version:
wget http://www-eu.apache.org/dist/xmlgraphics/batik/binaries/batik-bin-1.9.zip unzip batik-bin-1.9.zipln -s batik-1.9/batik-rasterizer-1.9.jar batik-rasterizer.jarln -s batik-1.9/lib libcd /opt/mathjaxnano mathjax.js- Put these lines in:
1 2 | var server = require('./node_modules/mathjax-server/index.js'); server.start(8003); |
- Start the server manually:
node mathjax.js - if there is something wrong, you will get: worker 4216 died. If all is fine, you will get: . If this do not work, find out the path of node with whereis node and try the start like this:/usr/local/bin/node mathjax.js
- Stop the server with
STRC+C - Now we create the start script:
nano /etc/init.d/ilmathjax - Copy the following in:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | #!/bin/bash ### BEGIN INIT INFO # Provides: ilmathjax2 # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: ILIAS-Mathjaxserver nodebased # Description: This file should be used to construct scripts to be # placed in /etc/init.d. ### END INIT INFO # Author: Wolfgang Hubesch wolfgang.huebsch@gmx.de # # Please remove the "Author" lines above and replace them # with your own name if you copy and modify this script. # Do NOT "set -e" # PATH should only include /usr/* if it runs after the mountnfs.sh script PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="ilmathjax" NAME=ilmathjax SCRIPTNAME=/etc/init.d/$NAME USER=www-data nodepath=/usr/local/bin/node scriptpath=/opt/mathjax/mathjax.js code="${nodepath} ${scriptpath}" ####################################################################################################################### code="${nodepath} ${scriptpath}" status=$(ps aux | grep ${scriptpath}) case "$1" in start) if [[ $status == *${code}* ]]; then echo "Mathjax is already running...exit now..." exit else echo "Mathjax is down...try to start..." { sudo -H -u $USER bash -c "${nodepath} ${scriptpath}" & } &> /dev/null status=$(ps aux | grep ${scriptpath}) if [[ $status == *${code}* ]]; then echo "Mathjax service runs now as user $USER" exit else echo "Fail to start Mathjax with user $USER. Please try user root instead if $USER" exit fi fi ;; stop) if [[ $status == *${code}* ]]; then echo "Mathjax is running...try to stop..." kill $(ps aux | grep mathjax.js | awk '{print $2}') > /dev/null 2>&1 #kill $(ps aux | grep mathjax | awk '{print $2}') > /dev/null 2>&1 exit else echo "Mathjax is already down..." exit fi ;; status) if [[ $status == *${code}* ]]; then echo "Mathjax is running...exit now..." exit else echo "Mathjax is down...exit now..." exit fi ;; *) echo "Usage: $0 {start|stop|status}" exit 1 esac |
- Check if the node path in line 5 is correct:
whereis node - Make the scripts executable:
chmod +x /etc/init.d/ilmathjax update-rc.d ilmathjax defaults 93- Update crontab:
nano /etc/crontab - Put the following lines in before the last #:
1 2 | #Mathjax */5 * * * * root /etc/init.d/ilmathjax start > /dev/null 2>&1 |
That means, the script checks every 5 minutes if the mathjax server is running. Replace mathjax with root if the script does not run and check the rightsetting.
- Activate Mathjax in ILIAS-Administration->Third party software->mathjax: