1

When I try <?php exec('/usr/bin/pandoc file -o file.pdf'); ?> no file is created. All formats works except the pdf format.

I think the problem is about the configuration server (debian 7 + nginx) and the function exec().

Whereas this command /usr/bin/pandoc file -o file.pdf works in a terminal.

Thanks for your help

Same problem as PHP shell_exec wait for script to done?

I have this problem with the logs: pandoc: PATH: getEnv: does not exist (no environment variable)

Community
  • 1
  • 1
n1c01a5
  • 88
  • 9

1 Answers1

2

I try exec("pandoc --latex-engine=xelatex --from=markdown -s -S -o /tmp/pandoc.pdf --toc /tmp/pandoc > debug.log 2>&1"); to debug because nothing errors appear.

The log file show the PATH is not defined. I think because it's www-data who executes this script. I must define this global var.

So I try to define the env var PATH with PATH=/usr/bin: pandoc --latex-engine=xelatex --from=markdown -s -S -o /tmp/pandoc.pdf --toc /tmp/pandoc and it's works! :-)

It's also possible to define this var in /etc/nginx/sites-available/yoursite.com for a nginx server (or equivalent with apache) with

location ~ \.php$ {
    [...]
    include /etc/nginx/fastcgi.conf;
    fastcgi_pass unix:/tmp/php.socket;
    fastcgi_param PATH /usr/local/bin:/usr/bin:/bin:/your/path;
}

See https://github.com/jgm/pandoc/issues/1587

n1c01a5
  • 88
  • 9