This question already has an answer here:<ul><li> <a href="/questions/11240725/how-can-i-get-php-to-compile-a-latex-document-if-it-www-data-cant-get-access" dir="ltr" rel="nofollow">How can I get PHP to compile a LaTeX document if it (www-data) can't get access to the required packages?</a> <span class="question-originals-answer-count"> 4 answers </span> </li> </ul>
I want to use the shell_exec command to compile a very simple latex file in order to generate a report of sorts in the webpage.
I move to the folder where I created the tex file. If I issue the command (from console, by typing)
Everything works as expected.
The first thing I have tried is issuing the command in php:
$cmd_out = shell_exec("pdflatex " . $wcopy);
where $wcopy contains the full path of the file to be compiled (report.tex in the example). The latex file contained an image and at first the compilation failed because I was issuing the pdflatex command from the directory where the php script resides and both the picture and the report.tex files are in a different directory. I fixed that problem by modifying the latex file so that the image path is relative the directory where the php script is located.
The next time I tried to run the script I get this very misterious message from pdflatex:
pdfTeX error: pdflatex (file ecrm1095): Font ecrm1095 at 600 not found
I believe this has something to do the php function shell_exec, although I'm not sure.
Can any one tell me what I might be doing wrong? I added the whole bit of the image, because I think it might be a clue.
Adding requested information. The server is running in a Debian Linux Distribution and the user that will execute those commands is www-dataAnswer1:
This is running as part of a web page, presumably?
The problem is probably that your script is running as a different user. I expect it is running as
apache might well not have the right path configured, or the right Latex setup for finding font directories and the like.
You haven't given much detail as to what system you're running on, but you could try running it as
apache to see if you can reproduce the error. If this is Linux, then become root, then go into the right directory, and run
su - apache pdflatex report.tex
to see what happens. To become root, you might be able to use
su on its own, if you know the root password; or if you're on Ubuntu, try
to become root (and give it your own password), and then the line I previously suggested to run as