====== MathTeXのインストール ====== 今となっては[[http://www.mathjax.org|{{|MathJax}}]]があれば全て幸せということなのだが、不幸せの種は尽きないわけでMathTeXやらmimeTeXはいつでも有効。というわけでここではMathTeXをインストールしてみよう。 http://www.forkosh.com/mathtex.htmlを読め、ということなのだが - $\TeX$ ($\LaTeX$)のタイプセッタと''dvipng''のインストール $ sudo apt install texlive-full こんな感じでインストールできる。dvipngも同時にインストールされるはずだが、もしインストールされない場合は $ sudo apt install dvipng どちらも $ latex --version pdfTeX 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian) kpathsea version 6.2.1 Copyright 2015 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX). There is NO warranty. Redistribution of this software is covered by the terms of both the pdfTeX copyright and the Lesser GNU General Public License. For more information about these matters, see the file named COPYING and the pdfTeX source. Primary author of pdfTeX: Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX). Compiled with libpng 1.6.17; using libpng 1.6.17 Compiled with zlib 1.2.8; using zlib 1.2.8 Compiled with poppler version 0.41.0 $ dvipng --version This is dvipng 1.15 Copyright 2002-2015 Jan-Ake Larsson dvipng 1.15 kpathsea version 6.2.1 Compiled with Freetype 2.5.2 Using libft 2.6.1 Copyright (C) 2002-2015 Jan-Ake Larsson. There is NO warranty. You may redistribute this software under the terms of the GNU Lesser General Public License version 3, see the COPYING file in the dvipng distribution or . $ みたいにすればチェックできる。 - MathTeXのダウンロード $ wget http://www.forkosh.com/mathtex.zip - MathTeXの展開 $ mkdir mathtex $ cp mathtex.zip mathtex/ $ cd mathtex $ unzip mathtex.zip 配布されているzipファイルはディレクトリごとアーカイブしたものではないのでディレクトリを切ってからそこで解凍すること。 - MathTeXのコンパイル $ cc mathtex.c -DLATEX=\"$(which latex)\" \ -DDVIPNG=\"$(which dvipng)\" \ -o mathtex.cgi $ 素のままのubuntu serverだとgccも入っていないのでgcc入れるとこからやる必要あり。 - mathtex.cgiのテスト $ ./mathtex.cgi "x^2+y^2" -m9 -o test +-----------------------------------------------------------------------+ |mathTeX vers 1.06 , Copyright(c) 2007-2017, John Forkosh Associates, Inc| +-----------------------------------------------------------------------+ | mathTeX is free software, licensed to you under terms of the GNU/GPL | | and comes with absolutely no warranty whatsoever. | | See http://www.forkosh.com/mathtex.html for complete details. | +-----------------------------------------------------------------------+ mathTeX> running image: ./mathtex.cgi mathTeX> home directory: /home/kimi/mathtex/ mathTeX> input expression: x^2+y^2 mathTeX> Built-in timelimit: warn/killtime=-1/10, path=none mathTeX> working directory: 8dfaf8281769c217b7e78b27a4747285 mathTeX> latex command executed: /usr/bin/latex latex.tex < reply.txt >latex.out 2>latex.err mathTeX> system() return status: 0 mathTeX> output image file: test.gif mathTeX> dvipng command executed: /usr/bin/dvipng --gif -D 120 --gamma 2.5 -bg Transparent -T tight -v -o ../test.gif latex.dvi >dvipng.out 2>dvipng.err $ ''test.gif''という名前の{{:linux:test.gif|こんなの}}ができていればOK - mathTeX(''mathtex.cgi'')のインストール $ sudo cp mathtex.cgi /usr/lib/cgi-bin/ $ sudo chown www-data.www-data /usr/lib/cgi-bin/mathtex.cgi $ sudo mkdir /usr/lib/cgi-bin/mathtex $ sudo chown -R www-data.www-data /usr/lib/cgi-bin/mathtex $ sudo a2enmod cgid $ sudo service apache2 restart ubuntu server 16.XX.XXのapache2の場合CGIスクリプトは''/usr/lib/cgi-bin''に置かれる。そこで出来上がった''mathtex.cgi''をコピーし、MathTeXのキャッシュディレクトリや作業用ディレクトリに適切なパーミッションを設定する。その後CGIスクリプトを有効化しapache2を再起動する。上記作業手順にはCGIスクリプトが作業用ディレクトリを作成できるようにする作業を意図的に記載していない。この部分をセキュアにする自信のない者はそもそもこういったことをしようと思ってはいけない。 - CGIスクリプトのテスト MathTeX動作テスト eq Webブラウザに上記のようなファイルを表示させてみて意図通りに表示されていればOK。