Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get PHP to compile a LaTeX document if it (www-data) can't get access to the required packages?

I have a PHP script that compiles LaTeX documents with the use of:

exec('cd /path/to/doc && /usr/bin/latexmk -pdf filename.tex');

This is working for some of my LaTeX documents but my latest document doesn't compile and a look at the log reveals:

!pdfTeX error: pdflatex (file ecrm1000): Font ecrm1000 at 600 not found
==> Fatal error occurred, no output PDF file produced!

Which I have found is the result of LaTeX not being able to see the required font packages. When I run the same compile command under my username the document compiles as it should. So my question is, how can I get PHP (executing as www-data) to get access to the necessary LaTeX packages?

I have tried installing the required package under the www-data account using:

sudo -u www-data sudo apt-get install texlive-fonts-recommended

but it askes for www-data's password, which I don't believe was set by me and isn't anything I've thrown at it.

I'm running Ubuntu 12.04 if it's any help.

like image 774
Mark Jones Avatar asked Jun 28 '12 08:06

Mark Jones


Video Answer


2 Answers

sudo mktexpk --destdir /usr/share/texmf-texlive/fonts/pk/ljfour/jknappen/ec/ --mfmode / --bdpi 600 --mag 1+0/600 --dpi 600 ecrm1000

... makes the font available for all users (same as in missingfont.log but with --destdir argument).

like image 158
Paul Voss Avatar answered Oct 05 '22 07:10

Paul Voss


I run with similar problem and it was solved by setting $HOME environment variable to /var/www in a shell-script which invoked pdflatex (or I believe any folder writeable to www-data is ok here). See the details on TeX.SX.

like image 43
Ilya V. Schurov Avatar answered Oct 05 '22 07:10

Ilya V. Schurov