-1

I have a php script test.php which invokes latex+biber:

`/usr/local/texlive/2016/bin/x86_64-linux/latex  --interaction batchmode test.tex `;
`/usr/local/texlive/2016/bin/x86_64-linux/biber  test`;

The script works fine if I run it from terminal php test.php (as root); it does not work when it is called from a browser http://localhost/test.php. In the latter case, I understand it is called from user apache. (I am testing on a Linux Fedora 29 machine).

The issue turns out to be related with `biber':

[root@fedora-pc]# su -s /bin/bash apache
bash-4.4$ /usr/local/texlive/2016/bin/x86_64-linux/biber test
Can't open test.blg (Permission denied) at /tmp/par-617061636865/cache-975de9a2a2c44ccaa5329d9695a54026ffc29f68/inc/lib/Log/Log4perl/Appender/File.pm line 151.

Also, I just discovered that

[root@fedora-pc 2019]# /usr/local/texlive/2016/bin/x86_64-linux/tlmgr update --list
/usr/local/texlive/2016/tlpkg/installer/xz/xzdec.x86_64-linux: (stdin): Unexpected end of input

[root@fedora-pc 2019]# tlmgr update --self
/usr/local/texlive/2016/tlpkg/installer/xz/xzdec.x86_64-linux: (stdin): Unexpected end of input
/usr/local/texlive/2016/bin/x86_64-linux/tlmgr: checksum error when downloading /tmp/WQEchRh21D/TzyO2wJ8pA from http://ftp.rrze.uni-erlangen.de/ctan/systems/texlive/tlnet/tlpkg/texlive.tlpdb: digest disagree

I am not so knowledgeable about LaTex to know what is going on and how to fix it. (biber is version 2.9)

  • It looks as though Biber is not allowed to write its log file (the .blg). If I'm not mistaken, Biber will try to write the .blg in the current working directory. Not sure what that would be in your case, but it might be in a place where you have no write permissions. The other errors have nothing to do with Biber and are TeX live infrastructure-related. TeX live 2016 is frozen and doesn't get any updates any more (just about current is TeX live 2018, TeX live 2019 should be released around May). – moewe Apr 13 at 18:13
  • 1
    It would be interesting to know if the LaTeX run works properly, I would have expected it to face similar permission issues with the .log file and all the auxiliary files. It should be noted, though, that Biber unpacks its executable into a temporary directory (in your case /tmp/par-617061636865/cache-975de9a2a2c44ccaa5329d9695a54026ffc29f68/) and runs from there. If programs in that path are restricted compared to programs in /usr/local/texlive/2016/bin/x86_64-linux/ and elsewhere (and it might not be unreasonable to apply such restrictions), that could explain things. – moewe Apr 13 at 18:22
  • Related question on Windows: tex.stackexchange.com/q/406960/35864. There it turned out that Bitdefender was blocking Biber (maybe even due to a heuristic that took issue with executables coming from a temporary folder). – moewe Apr 13 at 18:27
  • @moewe LaTeX run works properly. How do I check whether 'programs in that [tmp] path are restricted'? – mario Apr 13 at 20:12
  • Sorry, no idea, that would be more of a Linux question than a LaTeX question, I guess. – moewe Apr 14 at 4:04
0

Linux Fedora 29, 4.19.12-301.fc29.x86_64; pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2018) (I updated)

I fixed my issue when I added the following line to the sudoers file:

apache ALL=(ALL:ALL) NOPASSWD:/usr/local/texlive/2018/bin/x86_64-linux/biber

My script test.php is:

<?php

$NomeFile = 'test';
$bibFile = $NomeFile;
$texFile = $NomeFile.".tex";
$pdfFile = $NomeFile.".pdf";
$f=fopen($texFile,'w');

            $header ="\\documentclass{article} \n ";
            $header.="\\usepackage[latin1]{inputenc} \n ";
            $header.="\\usepackage[T1]{fontenc} \n ";
            $header.="\\usepackage[american,italian]{babel} \n ";
            $header.="\\usepackage[babel,italian=guillemets]{csquotes} \n ";
            $header.="\\usepackage[backend=biber,sorting=ynt]{biblatex}\n";
            $header.="\\usepackage[pdftex]{hyperref} \n ";

            $header.= "\\bibliography{".$bibFile."}";
            $header.="\\begin{document} \n ";

            $f=fopen($NomeFile.'.tex','w');
            fputs($f,$header);

fputs($f,"\\cite{Mario}"); 
$printbib = '\\printbibliography';
fputs($f,$printbib);
fputs($f,"\\end{document}");
fclose($f);

$filenameTeX = $NomeFile.'.tex'; 
$test_2 = `/usr/local/texlive/2018/bin/x86_64-linux/pdflatex  --interaction batchmode $texFile `;
$test_3 = `sudo -u root /usr/local/texlive/2018/bin/x86_64-linux/biber  $bibFile `;
$test_4 = `/usr/local/texlive/2018/bin/x86_64-linux/pdflatex  --interaction batchmode $texFile `;

$filenamePdf = $NomeFile.'.pdf'; 
echo "2 <pre>$test_2</pre>";
echo "3 <pre>$test_3</pre>";
echo "4 <pre>$test_4</pre>";
echo "<br><a href=\"$filenamePdf\">$filenamePdf</a>";
echo "<br><a href=\"$filenameTeX\">$filenameTeX</a>";
?>

my .bib file

@BOOK{Mario,
  author =      {Mario Doe},
  title =       {TITLE},
  publisher =   {My Pubblisher},
  location =    {World},
  year =        {2025} 
 }

I have set PAR_GLOBAL_TEMP=\var\www\tmp too, tmp owned by user apache, but it did not help.

A call from my browser http://localhost/test.php produces the wished test.tex and test.pdf files, bibliography included. /var/www/tmp/ remains empty. The same if I try by either [root@....]# php test.php or

[root@...]# su -s /bin/bash apache
bash-4.4$ php test.php

Note, if later I compile the .tex file, then /var/www/tmp/ gets polluted by a number of files, mainly within a inc sub-directory.

I am not sure this is the best solution, still it works for me, on a local settings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.