如何从PHP脚本编译.tex文件?我如何设置sudoers?

时间:2014-02-25 18:33:29

标签: php apache tex

我希望从php脚本中编译.tex文件,但编译部分失败(某些字体未呈现 - 请参阅下面的日志)。 我确定.tex文件很好,我可以从我的shell中以root身份编译它(在Fedora 17机器上)。 问题似乎是apache用户具有限制权限。

我正在尝试将权限设置为/ etc / sudoers,但我不确定如何编写它们。我尝试没有成功。

apache ALL = NOPASSWD: /usr/local/texlive/2013/bin/i386-linux/latex 
                       /usr/local/texlive/2013/bin/i386-linux/biber 
                       /usr/local/texlive/2013/bin/i386-linux/pdflatex
                       /usr/local/texlive/2013/bin/i386-linux/*

创建了missfont.log,它已经

mktextfm larm1728
mktextfm larm1000
mktextfm larm1200

我试图找到larm1728,但它不存在。

非常欢迎帮助,


LaTeX Font Info:    Try loading font information for T2A+wncyr on input line 2.

LaTeX Font Info:    No file T2Awncyr.fd. on input line 2.

LaTeX Font Warning: Font shape `T2A/wncyr/m/n' undefined (Font)  using `T2A/cmr/m/n'  instead on input line 2.

Font T2A/cmr/m/n/17.28=larm1728 at 17.28pt not loadable: Metric (TFM) file not found.
<to be read again> 
               relax 
l.2 ...xtcyrillic{Коминтерн}}{Komintern}}
I wasn't able to read the size data for this font,
so I will ignore the font specification.
[Wizards can fix TFM files using TFtoPL/PLtoTF.]
You might try inserting a different font spec;
e.g., type `I\font<same font id>=<substitute font name>'.

! Font T2A/wncyr/m/n/17.28=larm1728 at 17.28pt not loadable: Metric (TFM) file 
not found.

我有一些更新:

我给用户apache一个shell,然后这就是我得到的:

bash-4.2$ /usr/local/texlive/2013/bin/i386-linux/latex MyFile.tex
------
LaTeX Font Warning: Font shape `T2A/wncyr/m/n' undefined
(Font)              using `T2A/cmr/m/n' instead on input line 2.

kpathsea: Running mktextfm larm1728
mkdir: cannot create directory `././var/www/.texlive2013': 
Permission denied 
mktextfm: mktexdir /var/www/.texlive2013/texmf-var/fonts/tfm/lh/lh-t2a failed.
kpathsea: Appending font creation commands to missfont.log.
! Font T2A/cmr/m/n/17.28=larm1728 at 17.28pt not loadable: Metric (TFM)

(顺便说一下,为什么警告没有出现在日志文件中?)

现在,设置

chown apache:apache /var/www/

我改为

LaTeX Font Warning: Font shape `T2A/wncyr/m/n' undefined (Font)   
using `T2A/cmr/m/n' instead on input line 2.
kpathsea: Running mktextfm larm1728
mktextfm: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1;
nonstopmode; input larm1728
This is METAFONT, Version 2.718281 (TeX Live 2013)
kpathsea: Running mktexmf larm1728
mktexmf: /var/www/.texlive2013/texmf-var/fonts/source/lh/lh-t2a/larm1728.mf: 
successfully generated.
--snip--

然后我跑

bash-4.2$ /usr/local/texlive/2013/bin/i386-linux/biber  MyFile.bcf
bash-4.2$ /usr/local/texlive/2013/bin/i386-linux/pdflatex  MyFile.tex

并且输出非常好。

同样,如果运行

bash-4.2$ php direct.php    # direct.php is below

但如果我从我的客户端调用localhost // direct.php,它仍然存在 失败。

我遗失了什么,但是什么? 谢谢 马里奥

direct.php

<?php

echo '<hr>';
$nomeFile = 'MyFile';

$texFile = $nomeFile.".tex";
$bibFile = $nomeFile.'.bcf';
$pdfFile = $nomeFile.".pdf";

$test2 = `/usr/local/texlive/2013/bin/i386-linux/latex  --interaction
batchmode $texFile`;
$test21 = `/usr/local/texlive/2013/bin/i386-linux/biber    $bibFile`;
$test22 = `/usr/local/texlive/2013/bin/i386-linux/pdflatex
--interaction batchmode $texFile`;

echo "<pre>$test2</pre>";
echo "<pre>$test21</pre>";
echo "<pre>$test22</pre>";

echo "<br><a href=\"$texFile\">$texFile</a>";
echo "<br><a href=\"$pdfFile\">$pdfFile</a>";
?>

0 个答案:

没有答案