parpalak / i.upmath.me

Upmath LaTeX Renderer
https://i.upmath.me/
MIT License
54 stars 9 forks source link

cannot render latex on a locally run server #2

Closed walkerlala closed 7 years ago

walkerlala commented 7 years ago

Hi, I try to run the *tex.s2cms.ru server locally but got some problems.

I successfully bring up nginx server and I can see the index page at http://my.host.latex.net. (my.host.latex.net is my local host). But when I try to render the latex image using http://my.host.latex.net/svg/f(x)%20%3D%20x%20y, I got 502 Bad Gateway, and in the log file, I see something like fail to connect to php5-fpm-tex..... Then I check for /var/run/php5-fpm-tex and find only /var/run/php5-fpm-tex. How can I bring up this php5-fpm-tex? May be I miss configure something?

Actually when I configure this server I got something weird.

First of all when I try grunt it complain about

Running "shell:gzip_page" (shell) task
Warning: An error occurred while processing a template (Cannot read property 'dest' of undefined). Use --force to continue.

Clearly there is something miss in the shell:gzip entry in the gruntfile.js file. How can I fix this ?

I haven't set anything proc_open(), but I have ensured that in my php.ini , proc_open is not in the disable line.

The requirement say that I have to install Nginx with ngx_http_lua_module, so I use apt-get install nginx-extras in Ubuntu. Is this OK ?

Thanks!

parpalak commented 7 years ago

/var/run/php5-fpm-tex is a socket from my php-fpm config. You have to set up a virtual host in nginx with php-fpm. You can follow any instruction to do that.

I've removed unused "shell:gzip_page" task. Thanks for reporting.

proc_open() is a standard PHP function. Do you need help for it?

I use nginx-extras in Debian. I think the package in Ubuntu has the same functions.

walkerlala commented 7 years ago

So you mean that I have to setup both /var/run/php5-fpm-tex.sock and /var/run/php5-fpm.sock ? Can I setup only /var/run/php5-fmp.sock and use this for php-sock and php-tex-sock ?

proc_open() is OK in my machine now.

walkerlala commented 7 years ago

One more: the svg directory is still missing. When I use a browser to request something like http://my.host.latex.net/svg/f(x)%20%3D%20x%20y I see a net::ERR_CONNECTION_REFUSED error. Can you tell me how to fix this ?

parpalak commented 7 years ago

You can use only one socket /var/run/php5-fmp.sock in both locations. I've set up different sockets for several php-fpm pools because of security and performance. It's irrelevant for your case.

svg is not a name of a (real) directory. URLs /svg/... are processed with nginx and PHP. This error will disappear when you set up PHP.

walkerlala commented 7 years ago

Thanks, but I still cannot correctly render out latex image. Whenever I request a latex image (for example, http://my.latex.host.net/svg/%20%5Chat%7By_j%7D%20) I get a 200 response, but that is an empty response (my browser say This XML file does not appear to have any style information associated with it. The document tree is shown below.).

The log are list below:

the php5-fpm log:

- -  01/Jan/1970:08:00:00 +0800 "GET /render.php" 200 /var/www/html/tex.s2cms.ru/www/render.php 715081.150 512 0.03%

the nginx error.log:

2016/12/18 12:30:14 [error] 1415#0: *9 FastCGI sent in stderr: "PHP message: PHP Warning:  file_get_contents(/home/walkerlala/software/tex.s2cms.ru/www/tmp/ms76lH.svg): failed to open stream: No such file or directory in /home/walkerlala/software/tex.s2cms.ru/lib/Renderer.php on line 198" while reading response header from upstream, client: 127.0.0.1, server: oh.my.latex.net, request: "GET /svg/%20%5Chat%7By_j%7D%20 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "my.latex.host.net"

the nginx access.log:

127.0.0.1 - - [18/Dec/2016:12:30:14 +0800] "GET /svg/%20%5Chat%7By_j%7D%20 HTTP/1.1" 200 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36"

the tex_logs/log-----.txt is empty

FIles in directories _cache and _error are empty.

the /var/log/php5-fpm.log is empty.

For your information, /var/www/html/tex.s2cms.ru/www is the document root and /var/www/html/tex.s2cms.ru is simlinked to /home/walkerlala/softwares/tex.s2cms.ru, where the source exists.

Any hint?

walkerlala commented 7 years ago

p.s., when I put define('TEX_PATH', '/usr/bin'); in config.php, the tex path is generated as '/usr/bintex' and that crash. Changing it to define('TEX_PATH', '/usr/bin/'); makes it work correctly.

parpalak commented 7 years ago

Seems like dvisvgm is not installed on your system. To check this, try to run dvisvgm file.dvi -o file.svg on a separate dvi-file generated by latex.

Also you can enable the debug mode by adding define('DEBUG', 1); to config.php. You'll see the additional debug info directly in browser.

walkerlala commented 7 years ago

dvisvgm has been installed correctly.

This is the debug message when I request http://my.latex.host.net/svg/%20gradients%20:

\documentclass[11pt]{article} \batchmode \usepackage{amsmath} \usepackage{amssymb} \newcommand{\R}{\mathbb{R}} \usepackage[utf8]{inputenc} \pagestyle{empty}

\setlength{\topskip}{0pt} \setlength{\parindent}{0pt} \setlength{\abovedisplayskip}{0pt} \setlength{\belowdisplayskip}{0pt}

\begin{document} {$\displaystyle \special{dvisvgm:bbox new formula} \special{dvisvgm:raw} gradients$ \special{dvisvgm:raw}} \end{document} This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/Debian) (format=latex 2016.12.16) 18 DEC 2016 15:53 entering extended mode restricted \write18 enabled. %&-line parsing enabled. **/home/walkerlala/software/tex.s2cms.ru/www/tmp/8id5SJ (/home/walkerlala/software/tex.s2cms.ru/www/tmp/8id5SJ LaTeX2e <2011/06/27> Babel <3.9h> and hyphenation patterns for 2 languages loaded. (/usr/share/texlive/texmf-dist/tex/latex/base/article.cls Document Class: article 2007/10/19 v1.4h Standard LaTeX document class (/usr/share/texlive/texmf-dist/tex/latex/base/size11.clo File: size11.clo 2007/10/19 v1.4h Standard LaTeX file (size option) ) \c@part=\count79 \c@section=\count80 \c@subsection=\count81 \c@subsubsection=\count82 \c@paragraph=\count83 \c@subparagraph=\count84 \c@figure=\count85 \c@table=\count86 \abovecaptionskip=\skip41 \belowcaptionskip=\skip42 \bibindent=\dimen102 ) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty Package: amsmath 2013/01/14 v2.14 AMS math features \@mathmargin=\skip43 For additional information on amsmath, use the ''?' option. (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty Package: amstext 2000/06/29 v2.01 (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty File: amsgen.sty 1999/11/30 v2.0 \@emptytoks=\toks14 \ex@=\dimen103 )) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty Package: amsbsy 1999/11/29 v1.2d \pmbraise@=\dimen104 ) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty Package: amsopn 1999/12/14 v2.01 operator names ) \inf@bad=\count87 LaTeX Info: Redefining \frac on input line 210. \uproot@=\count88 \leftroot@=\count89 LaTeX Info: Redefining \overline on input line 306. \classnum@=\count90 \DOTSCASE@=\count91 LaTeX Info: Redefining \ldots on input line 378. LaTeX Info: Redefining \dots on input line 381. LaTeX Info: Redefining \cdots on input line 466. \Mathstrutbox@=\box26 \strutbox@=\box27 \big@size=\dimen105 LaTeX Font Info: Redeclaring font encoding OML on input line 566. LaTeX Font Info: Redeclaring font encoding OMS on input line 567. \macc@depth=\count92 \c@MaxMatrixCols=\count93 \dotsspace@=\muskip10 \c@parentequation=\count94 \dspbrk@lvl=\count95 \tag@help=\toks15 \row@=\count96 \column@=\count97 \maxfields@=\count98 \andhelp@=\toks16 \eqnshift@=\dimen106 \alignsep@=\dimen107 \tagshift@=\dimen108 \tagwidth@=\dimen109 \totwidth@=\dimen110 \lineht@=\dimen111 \@envbody=\toks17 \multlinegap=\skip44 \multlinetaggap=\skip45 \mathdisplay@stack=\toks18 LaTeX Info: Redefining [ on input line 2665. LaTeX Info: Redefining ] on input line 2666. ) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amssymb.sty Package: amssymb 2013/01/14 v3.01 AMS font symbols (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amsfonts.sty Package: amsfonts 2013/01/14 v3.01 Basic AMSFonts support \symAMSa=\mathgroup4 \symAMSb=\mathgroup5 LaTeX Font Info: Overwriting math alphabet \mathfrak' in versionbold' (Font) U/euf/m/n --> U/euf/b/n on input line 106. )) (/usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty Package: inputenc 2008/03/30 v1.1d Input encoding file \inpenc@prehook=\toks19 \inpenc@posthook=\toks20 (/usr/share/texlive/texmf-dist/tex/latex/base/utf8.def File: utf8.def 2008/04/05 v1.1m UTF-8 support for inputenc Now handling font encoding OML ... ... no UTF-8 mapping file for font encoding OML Now handling font encoding T1 ... ... processing UTF-8 mapping file for font encoding T1 (/usr/share/texlive/texmf-dist/tex/latex/base/t1enc.dfu File: t1enc.dfu 2008/04/05 v1.1m UTF-8 support for inputenc defining Unicode char U+00A1 (decimal 161) defining Unicode char U+00A3 (decimal 163) defining Unicode char U+00AB (decimal 171) defining Unicode char U+00BB (decimal 187) defining Unicode char U+00BF (decimal 191) defining Unicode char U+00C0 (decimal 192) defining Unicode char U+00C1 (decimal 193) defining Unicode char U+00C2 (decimal 194) defining Unicode char U+00C3 (decimal 195) defining Unicode char U+00C4 (decimal 196) defining Unicode char U+00C5 (decimal 197) defining Unicode char U+00C6 (decimal 198) defining Unicode char U+00C7 (decimal 199) defining Unicode char U+00C8 (decimal 200) defining Unicode char U+00C9 (decimal 201) defining Unicode char U+00CA (decimal 202) defining Unicode char U+00CB (decimal 203) defining Unicode char U+00CC (decimal 204) defining Unicode char U+00CD (decimal 205) defining Unicode char U+00CE (decimal 206) defining Unicode char U+00CF (decimal 207) defining Unicode char U+00D0 (decimal 208) defining Unicode char U+00D1 (decimal 209) defining Unicode char U+00D2 (decimal 210) defining Unicode char U+00D3 (decimal 211) defining Unicode char U+00D4 (decimal 212) defining Unicode char U+00D5 (decimal 213) defining Unicode char U+00D6 (decimal 214) defining Unicode char U+00D8 (decimal 216) defining Unicode char U+00D9 (decimal 217) defining Unicode char U+00DA (decimal 218) defining Unicode char U+00DB (decimal 219) defining Unicode char U+00DC (decimal 220) defining Unicode char U+00DD (decimal 221) defining Unicode char U+00DE (decimal 222) defining Unicode char U+00DF (decimal 223) defining Unicode char U+00E0 (decimal 224) defining Unicode char U+00E1 (decimal 225) defining Unicode char U+00E2 (decimal 226) defining Unicode char U+00E3 (decimal 227) defining Unicode char U+00E4 (decimal 228) defining Unicode char U+00E5 (decimal 229) defining Unicode char U+00E6 (decimal 230) defining Unicode char U+00E7 (decimal 231) defining Unicode char U+00E8 (decimal 232) defining Unicode char U+00E9 (decimal 233) defining Unicode char U+00EA (decimal 234) defining Unicode char U+00EB (decimal 235) defining Unicode char U+00EC (decimal 236) defining Unicode char U+00ED (decimal 237) defining Unicode char U+00EE (decimal 238) defining Unicode char U+00EF (decimal 239) defining Unicode char U+00F0 (decimal 240) defining Unicode char U+00F1 (decimal 241) defining Unicode char U+00F2 (decimal 242) defining Unicode char U+00F3 (decimal 243) defining Unicode char U+00F4 (decimal 244) defining Unicode char U+00F5 (decimal 245) defining Unicode char U+00F6 (decimal 246) defining Unicode char U+00F8 (decimal 248) defining Unicode char U+00F9 (decimal 249) defining Unicode char U+00FA (decimal 250) defining Unicode char U+00FB (decimal 251) defining Unicode char U+00FC (decimal 252) defining Unicode char U+00FD (decimal 253) defining Unicode char U+00FE (decimal 254) defining Unicode char U+00FF (decimal 255) defining Unicode char U+0102 (decimal 258) defining Unicode char U+0103 (decimal 259) defining Unicode char U+0104 (decimal 260) defining Unicode char U+0105 (decimal 261) defining Unicode char U+0106 (decimal 262) defining Unicode char U+0107 (decimal 263) defining Unicode char U+010C (decimal 268) defining Unicode char U+010D (decimal 269) defining Unicode char U+010E (decimal 270) defining Unicode char U+010F (decimal 271) defining Unicode char U+0110 (decimal 272) defining Unicode char U+0111 (decimal 273) defining Unicode char U+0118 (decimal 280) defining Unicode char U+0119 (decimal 281) defining Unicode char U+011A (decimal 282) defining Unicode char U+011B (decimal 283) defining Unicode char U+011E (decimal 286) defining Unicode char U+011F (decimal 287) defining Unicode char U+0130 (decimal 304) defining Unicode char U+0131 (decimal 305) defining Unicode char U+0132 (decimal 306) defining Unicode char U+0133 (decimal 307) defining Unicode char U+0139 (decimal 313) defining Unicode char U+013A (decimal 314) defining Unicode char U+013D (decimal 317) defining Unicode char U+013E (decimal 318) defining Unicode char U+0141 (decimal 321) defining Unicode char U+0142 (decimal 322) defining Unicode char U+0143 (decimal 323) defining Unicode char U+0144 (decimal 324) defining Unicode char U+0147 (decimal 327) defining Unicode char U+0148 (decimal 328) defining Unicode char U+014A (decimal 330) defining Unicode char U+014B (decimal 331) defining Unicode char U+0150 (decimal 336) defining Unicode char U+0151 (decimal 337) defining Unicode char U+0152 (decimal 338) defining Unicode char U+0153 (decimal 339) defining Unicode char U+0154 (decimal 340) defining Unicode char U+0155 (decimal 341) defining Unicode char U+0158 (decimal 344) defining Unicode char U+0159 (decimal 345) defining Unicode char U+015A (decimal 346) defining Unicode char U+015B (decimal 347) defining Unicode char U+015E (decimal 350) defining Unicode char U+015F (decimal 351) defining Unicode char U+0160 (decimal 352) defining Unicode char U+0161 (decimal 353) defining Unicode char U+0162 (decimal 354) defining Unicode char U+0163 (decimal 355) defining Unicode char U+0164 (decimal 356) defining Unicode char U+0165 (decimal 357) defining Unicode char U+016E (decimal 366) defining Unicode char U+016F (decimal 367) defining Unicode char U+0170 (decimal 368) defining Unicode char U+0171 (decimal 369) defining Unicode char U+0178 (decimal 376) defining Unicode char U+0179 (decimal 377) defining Unicode char U+017A (decimal 378) defining Unicode char U+017B (decimal 379) defining Unicode char U+017C (decimal 380) defining Unicode char U+017D (decimal 381) defining Unicode char U+017E (decimal 382) defining Unicode char U+200C (decimal 8204) defining Unicode char U+2013 (decimal 8211) defining Unicode char U+2014 (decimal 8212) defining Unicode char U+2018 (decimal 8216) defining Unicode char U+2019 (decimal 8217) defining Unicode char U+201A (decimal 8218) defining Unicode char U+201C (decimal 8220) defining Unicode char U+201D (decimal 8221) defining Unicode char U+201E (decimal 8222) defining Unicode char U+2030 (decimal 8240) defining Unicode char U+2031 (decimal 8241) defining Unicode char U+2039 (decimal 8249) defining Unicode char U+203A (decimal 8250) defining Unicode char U+2423 (decimal 9251) ) Now handling font encoding OT1 ... ... processing UTF-8 mapping file for font encoding OT1 (/usr/share/texlive/texmf-dist/tex/latex/base/ot1enc.dfu File: ot1enc.dfu 2008/04/05 v1.1m UTF-8 support for inputenc defining Unicode char U+00A1 (decimal 161) defining Unicode char U+00A3 (decimal 163) defining Unicode char U+00B8 (decimal 184) defining Unicode char U+00BF (decimal 191) defining Unicode char U+00C5 (decimal 197) defining Unicode char U+00C6 (decimal 198) defining Unicode char U+00D8 (decimal 216) defining Unicode char U+00DF (decimal 223) defining Unicode char U+00E6 (decimal 230) defining Unicode char U+00EC (decimal 236) defining Unicode char U+00ED (decimal 237) defining Unicode char U+00EE (decimal 238) defining Unicode char U+00EF (decimal 239) defining Unicode char U+00F8 (decimal 248) defining Unicode char U+0131 (decimal 305) defining Unicode char U+0141 (decimal 321) defining Unicode char U+0142 (decimal 322) defining Unicode char U+0152 (decimal 338) defining Unicode char U+0153 (decimal 339) defining Unicode char U+2013 (decimal 8211) defining Unicode char U+2014 (decimal 8212) defining Unicode char U+2018 (decimal 8216) defining Unicode char U+2019 (decimal 8217) defining Unicode char U+201C (decimal 8220) defining Unicode char U+201D (decimal 8221) ) Now handling font encoding OMS ... ... processing UTF-8 mapping file for font encoding OMS (/usr/share/texlive/texmf-dist/tex/latex/base/omsenc.dfu File: omsenc.dfu 2008/04/05 v1.1m UTF-8 support for inputenc defining Unicode char U+00A7 (decimal 167) defining Unicode char U+00B6 (decimal 182) defining Unicode char U+00B7 (decimal 183) defining Unicode char U+2020 (decimal 8224) defining Unicode char U+2021 (decimal 8225) defining Unicode char U+2022 (decimal 8226) ) Now handling font encoding OMX ... ... no UTF-8 mapping file for font encoding OMX Now handling font encoding U ... ... no UTF-8 mapping file for font encoding U defining Unicode char U+00A9 (decimal 169) defining Unicode char U+00AA (decimal 170) defining Unicode char U+00AE (decimal 174) defining Unicode char U+00BA (decimal 186) defining Unicode char U+02C6 (decimal 710) defining Unicode char U+02DC (decimal 732) defining Unicode char U+200C (decimal 8204) defining Unicode char U+2026 (decimal 8230) defining Unicode char U+2122 (decimal 8482) defining Unicode char U+2423 (decimal 9251) )) No file 8id5SJ.aux. \openout1 = `8id5SJ.aux'.

LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 14. LaTeX Font Info: ... okay on input line 14. LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 14. LaTeX Font Info: ... okay on input line 14. LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 14. LaTeX Font Info: ... okay on input line 14. LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 14. LaTeX Font Info: ... okay on input line 14. LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 14. LaTeX Font Info: ... okay on input line 14. LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 14. LaTeX Font Info: ... okay on input line 14. LaTeX Font Info: Try loading font information for U+msa on input line 15. (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsa.fd File: umsa.fd 2013/01/14 v3.01 AMS symbols A ) LaTeX Font Info: Try loading font information for U+msb on input line 15. (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsb.fd File: umsb.fd 2013/01/14 v3.01 AMS symbols B ) [1

] (tmp//8id5SJ.aux) ) Here is how much of TeX's memory you used: 1314 strings out of 495029 14292 string characters out of 6181522 60312 words of memory out of 5000000 4554 multiletter control sequences out of 15000+600000 8288 words of font info for 32 fonts, out of 8000000 for 9000 14 hyphenation exceptions out of 8191 27i,4n,26p,265b,102s stack positions out of 5000i,500n,10000p,200000b,80000s

Output written on tmp//8id5SJ.dvi (1 page, 324 bytes). string(8) "exitcode" int(0) string(174) "/usr/bin/dvisvgm /home/walkerlala/software/tex.s2cms.ru/www/tmp/8id5SJ -o /home/walkerlala/software/tex.s2cms.ru/www/tmp/8id5SJ.svg -n --exact -v0 --relative --zoom=1.2546875" NULL

Any hint?

parpalak commented 7 years ago

You can try to comment (or remove) $this->cleanupTempFiles($tmpName); at the following line.

After that examine the /home/walkerlala/software/tex.s2cms.ru/www/tmp/ dir and try to convert files "by hand". In particular, check the command

/usr/bin/dvisvgm <file>.dvi -o <file>.svg -n --exact --relative --zoom=1.2546875

without -v0 option for error messages.

walkerlala commented 7 years ago

In log/error.log, I get:

2016/12/18 16:40:53 [error] 1415#0: *43 FastCGI sent in stderr: "PHP message: PHP Warning:  file_get_contents(/home/walkerlala/software/tex.s2cms.ru/www/tmp/8BeVgT.svg): failed to open stream: No such file or directory in /home/walkerlala/software/tex.s2cms.ru/lib/Renderer.php on line 198
PHP message: PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/walkerlala/software/tex.s2cms.ru/lib/Renderer.php:168) in /home/walkerlala/software/tex.s2cms.ru/lib/Processor.php on line 137
PHP message: PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/walkerlala/software/tex.s2cms.ru/lib/Renderer.php:168) in /home/walkerlala/software/tex.s2cms.ru/lib/Processor.php on line 145
PHP message: PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/walkerlala/software/tex.s2cms.ru/lib/Renderer.php:168) in /home/walkerlala/software/tex.s2cms.ru/lib/Processor.php on line 146" while reading upstream, client: 127.0.0.1, server: oh.my.latex.net, request: "GET /svg/%20gradients%20 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "oh.my.latex.net"

There is a /home/walkerlala/software/tex.s2cms.ru/www/tmp/8BeVgT.svg on my machine, but it has no 8BeVgT.svg, only 8BeVgT.dvi.

What am I missing ?

parpalak commented 7 years ago

Well, try to run dvisvgm for 8BeVgT.dvi as I wrote above. There must be a error message.

walkerlala commented 7 years ago

No there is no error message. It just output:

processing page 1 [1]
    page size: 46.3442pt x 9.84405pt (16.2881mm x 3.45979mm)
    page written to 8BeVgT.svg
1 of 1 page converted in 0.0500941 seconds

(p.s., I try to run /usr/bin/dvisvgm 8BeVgT.dvi -o 8BeVgT.svg -n --exact --relative --zoom=1.2546875 but it complain about unknown option --relative and unknown option --zoom so I remove those two

parpalak commented 7 years ago

Maybe that's the reason. These options are described in the dvisvgm documentation. You could replace the options in the dvisvg command or install a fresh version of dvisvgm or TeX Live.

walkerlala commented 7 years ago

Yes, you are right. On my ubuntu 14.04, dvisvgm is provided by package texlive-binaries and is a pretty old version(1.02). I compile the newest version(2.04) myself and it work correctly. Thanks.