Flag This Hub

Installing MathTex on DreamHost

By


Why I Needed LaTeX

I run an engineering site devoted to Aerospace and Control Systems.  The site is a wiki based on MediaWiki and being an engineering site it is heavy on the math.  In fact the math is the primary focus of most of the articles on the wiki.

There are a few ways to generate complex equations in MediaWiki.  The first is to use texvc (which comes with MediaWiki).  I tried this and it worked - for a while.  Then my hosting company did something and it just stopped working one day.  The other downside was that the LaTeX for texvc did not appear to be 100% compatible with the LaTeX used on Wikipedia and other sources.

That led me to alter the Math.php file (in the includes subdirectory) to call a program named MathTex.cgi render the LaTeX as pngs.  At first there were several public MathTex installations but as time went on the installations began to go away or no longer be public.  Since my site was so heavy on math I decided to attempt to create my own, most likely private, MathTex installation.

Why I chose DreamHost

As I began to expand my web presence, with other sites, it became clear that my current host just didn't offer the necessary resources for what I needed including MathTex.  When I first started looking into MathTex I was contacted by the creator, John Forkosh, because I was hitting his hosting account too hard.  At that time I learned he hosts his account on DreamHost (something you can also learn from his page on MathTex).

My two primary hosting choices were HostGator and DreamHost.  Given Forkosh was on DreamHost it had a leg up from the beginning.  However, the other factor was the ability to get Private Server capability a little at a time.  Given that I am hosting MathTex for myself for the first time I thought it prudent to have the ability to buy extra resources without jumping all the way to a full up Virtual Private Server (much more expensive than traditional shared hosting).

Installation Prerequisites

John Forkosh's site provides good instructions on the installation but like any installation there are always little, important, details.  There are 2 dependencies:

  • LaTeX
  • dvipng

On DreamHost LaTeX was already available and the scripts for dvipng were already available.  However, when I attempted to compile dvipng the compilation program just couldn't find either - even after I pointed it to them.  So I assume there were permissions issues.

So I took a step back and installed texlive (link available on Forkosh's site).  If you follow the instructions provided by texlive the installation won't work.  The texlive instructions suggest that you install under ~/texlive.  However, the installation of texlive fails when it is done in ~/texlive.

I finally got texlive to install under a domain folder.  My first domain with DreamHost was Controls-Design.com so I installed under ~/controls-design.com/texlive.  Thankfully texlive is a LaTeX installation that came with dvipng.  Once I installed texlive under my domain everything went easy.


MathTex Installation

Here's the compilation command:

cc –DLATEX=\"path/to/latex\" DDVIPNG=\"path/to/dvipng\" mathtex.c –o mathtex.cgi

In my case I installed texlive under ~/controls-design.com/texlive meaning that latex and dvipng are under ~/controls-design.com/texlive/2008/bin/x86_64-linux. So the above command becomes:

cc –DLATEX=\"~/controls-design.com/texlive/2008/bin/x86_64-linux/latex\" DDVIPNG=\"~/controls-design.com/texlive/2008/bin/x86_64-linux/dvipng\" mathtex.c –o mathtex.cgi

There are 2 items of note:

  1. The above command will create a public version of MathTex that anyone can use. If you wish to limit who can use it then you must use the -DREFERER switch and provide it with the correct domains.
  2. The default compilation sets up MathTex to produce gifs from the LaTeX string. However, these gifs are not high quality and the pngs that MathTex produces are much better quality. This requires the -DPNG switch so that MathTex produces png files by default.

So my final command was this (for the private version):

cc –DLATEX=\"~/controls-design.com/texlive/2008/bin/x86_64-linux/latex\" DDVIPNG=\"~/controls-design.com/texlive/2008/bin/x86_64-linux/dvipng\" -DREFERER=\"controls-design.com\" -DPNG mathtex.c –o mathtex.cgi

and this (for the public version):

cc –DLATEX=\"~/controls-design.com/texlive/2008/bin/x86_64-linux/latex\" DDVIPNG=\"~/controls-design.com/texlive/2008/bin/x86_64-linux/dvipng\" -DPNG mathtex.c –o public_mathtex.cgi

Both of these commands come from the directory where the MathTex.c file exists. I may open up a free public version but given the likely resource requirements will require that I don't.

MathTex Interest Poll

I'm considering providing a public MathTex but given the resource requirements it may need to be a paid service. How much would you be willing to pay per 10,000 images?

  • $5
  • $10
  • more
See results without voting

Public MathTex

As I've found many public MathTex installations don't remain public.  This is most likely because of the hosting resource requirements that come with lots of websites hitting one domain with MathTex requests.  As a result, if there is enough interest in a paid service I will work to create one.

Good internet etiquette requires that I get John Forkosh's permission before I create a paid version.  However, if I were able to create a paid public MathTex version it would have to be on a per image basis - something like $5 per 10k images.  But this is just a guess because I'll have to see how many resources MathTex requires.  I will most likely need to upgrade my hosting in order to accommodate more than a few websites hitting my domain.

Guide to LaTeX (4th Edition)
Amazon Price: $39.35
List Price: $59.99
LaTeX Beginner's Guide
Amazon Price: $38.63
List Price: $44.99
The LaTeX Companion (Tools and Techniques for Computer Typesetting)
Amazon Price: $49.50
List Price: $69.99
More Math Into LaTeX, 4th Edition
Amazon Price: $45.16
List Price: $64.95
LaTeX: A Document Preparation System (2nd Edition)
Amazon Price: $28.00
List Price: $49.99

Comments

Danny Milosavljevic 2 years ago

Hi,

>I run an engineering site devoted to Aerospace and Control Systems.

Very cool.

I'm trying to get my physics knowledge online in some readable form :-)

> John Forkosh's site provides good instructions on the installation

I'm reading http://www.forkosh.com/mathtex.html right now, hmm...

When you say

>... the scripts for dvipng were already available. However, when I attempted to compile dvipng...

what do you mean? Available where and how was it supposed to work? A script wouldn't need to be compiled, would it?

Maybe I'm just too tired :-)

cheers,

Danny

spradlig 2 years ago

Sorry I wasn't clear but I meant when I attempted to compile mathtex that dvipng wasn't available. So I had to install texlive under one of my domains. Then dvipng was available under the texlive installation. Point the mathtex compilation at your texlive install (and the appropriate subfolders) and it should go smoothly.

I attempted several installations and was successful with all that I hadn't screwed up in some way (i.e., pointing at the wrong directories, etc). I was able to easily create both public and private versions of the mathtex script.

Submit a Comment
Members and Guests

Sign in or sign up and post using a hubpages account.



    Like this Hub?
    Please wait working