如果 (www-data) 无法访问所需的包,我如何让 PHP 编译 LaTeX 文档?

2022-01-24 00:00:00 latex ubuntu php pdflatex

我有一个 PHP 脚本,它使用以下代码编译 LaTeX 文档:

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

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

这适用于我的一些 LaTeX 文档,但我的最新文档无法编译,查看日志显示:

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!

我发现是 LaTeX 无法看到所需的字体包的结果.当我在我的用户名下运行相同的编译命令时,文档会按应有的方式编译.所以我的问题是,我怎样才能让 PHP(作为 www-data 执行)来访问必要的 LaTeX 包?

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?

我已尝试使用以下方式在 www-data 帐户下安装所需的软件包:

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

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

但它要求输入 www-data 的密码,我不相信这是我设置的,也不是我扔给它的任何东西.

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.

如果有帮助,我正在运行 Ubuntu 12.04.

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

推荐答案

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

... 使所有用户都可以使用该字体(与 missingfont.log 中的相同,但带有 --destdir 参数).

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

相关文章