1

I want to compile a latex file via php. Therefore I use

shell_exec("/usr/bin/xelatex --output-directory=output/ --interaction batchmode doc.tex");

The problem I ran into is that the www-data user on my Apache webserver is not able to use some installed LaTeX packages. I believe (but I'm not sure) it has something to do with a home dir. And my www-data has none (or so I think).

By the way, I use TexLive on the server.

Edit: Here's my code of the php compiling

This is XeTeX, Version 3.14159265-2.6-0.99998 (TeX Live 2017/Debian) (preloaded format=xelatex 2018.6.16)  18 JUN 2018 07:13
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**/var/www/html/tennessee/wp-content/plugins/daw_songbook/tmp/doc.tex
(/var/www/html/tennessee/wp-content/plugins/daw_songbook/tmp/doc.tex
LaTeX2e <2017-04-15>
Babel <3.10> and hyphenation patterns for 8 language(s) loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/book.cls
Document Class: book 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/bk10.clo
File: bk10.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
)
\c@part=\count79
\c@chapter=\count80
\c@section=\count81
\c@subsection=\count82
\c@subsubsection=\count83
\c@paragraph=\count84
\c@subparagraph=\count85
\c@figure=\count86
\c@table=\count87
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
)

! LaTeX Error: File `songs.sty' not found.

Type X to quit or <RETURN> to proceed, or enter new name. (Default extension: sty)

Enter file name: ! Emergency stop. <read *>

l.5 \usepackage {amsmath}^^M *** (cannot \read from terminal in nonstop modes)

Here is how much of TeX's memory you used: 225 strings out of 494938 2641 string characters out of 6176411 55952 words of memory out of 5000000 4170 multiletter control sequences out of 15000+600000 3648 words of font info for 15 fonts, out of 8000000 for 9000 14 hyphenation exceptions out of 8191 22i,0n,19p,169b,40s stack positions out of 5000i,500n,10000p,200000b,80000s No pages of output.

Ingmar
  • 6,690
  • 5
  • 26
  • 47
  • Could you please show us how you came to your conclusion with the inability to use some packages? – TeXnician Jun 18 '18 at 05:53
  • I tried to compile the same file with several "normal" users and with sudo on the server. Everytime with success. And I found a copy of the used installed packages in the Home dirs. – Da Windy Jun 18 '18 at 05:57
  • Can you obtain the .log file of the XeLaTeX run? – moewe Jun 18 '18 at 06:17
  • Yes I do. The logfile says, that the package.sty is not found. So a pdf is not created. – Da Windy Jun 18 '18 at 06:24
  • With TeX Live there should not be any installed packages in the home directory (if you have a proper server installation). So something on your setup is non-standard. Could you maybe post your log file here? – TeXnician Jun 18 '18 at 06:35
  • Why is the first package you want to load songs? Are you sure you need it? – Johannes_B Jun 18 '18 at 06:58
  • I just checked the log after compiling successfully via command line as a user. There I found out, that the specific package really is located in my Home Dir... I don't get it. I installed it with tlmgr. – Da Windy Jun 18 '18 at 07:01
  • the songs package is essential for the document. – Da Windy Jun 18 '18 at 07:02

1 Answers1

0

OK... I think I did it.

tlmgr installs packages only in the home dir of the users. That is a problem, because when I want php to compile it via shell_exec, the www-data user of my server does not have the package.

So instead of installing it via tlmgr I installed it manually in /tex/latex/ and after that I run mktexlsr .

The www-data user does now search and find the package in the global base dir and not inside a local home dir.

Thanks to the following link (Method 3): How do I install an individual package on a Linux system?

  • 2
    You should still use tlmgr, but as root, so that it will be in global scope. – TeXnician Jun 18 '18 at 08:58
  • 1
    I'd also have thought that if tlmgr is run as root it would install packages for all users in the shared directory and not in home. Letting tlmgr manage things instead of installing manually is normally the infinitely better choice. – moewe Jun 18 '18 at 09:56
  • I am running into the same problem. So I need to copy a ton of stuff to the system-wide file? –  May 07 '21 at 01:49