Feb 4, 2014

Compile Mathex (A Latex CGI to generate image)

Mathtex from http://www.forkosh.com/mathtex.html

If we careless compile, we can easily produced the error:
cc: error: –DSOMETHING="xyz": No such file or directory
Which really not makes sense at all.
Actually, it maybe some switches is not supported, or the value is not correctly quoted.

I made it worked with Nginx by using fcgiwrap
       location ~ ^/tex.cgi$ {
                gzip off;
                fastcgi_pass unix:/var/run/fcgiwrap.socket;
                include fastcgi_params;
        }
Complie:
cc mathtex.c -o tex.cgi -DDVIPNG=\"/usr/bin/dvipng\" -DLATEX=\"/usr/bin/latex\" -DCACHE=\"cache\/\" DWORK=\"cache\/\"

The most important switches are DCACHE (set up relative cache dir) and DWORK (set up temporary place for the CGI works). They should both writable by the script tex.cgi under fcgiwrap's run user.

Then place stuff using at this structure:
/public
          /cache
          tex.cgi