I got a problem when converting doc to pdf using libreoffice5 in php.
I wrote a Linux shell to convert a office doc document to pdf (t.sh):
#!/bin/sh
libreoffice5.0 --headless --invisible --convert-to pdf --outdir $1 $2
Then I created a php file in apache htdocs dir as follows (mytest.php):
<?php
$cmd = './t.sh ./ ./55ffbc34c3808.docx';
var_dump($cmd);
$rtn = exec($cmd, $rtnResult, $rtnVal);
var_dump($rtnResult);
But when I run http://localhost/mytest.php, the page never stop and no result was printed (no pdf was generated). When I run ps -ef|grep libre, I saw the following:
maijin 10403 10402 0 03:11 ? 00:00:00 /opt/libreoffice5.0/program/oosplash --headless --invisible --convert-to pdf --outdir ./ ./55ffbc34c3808.docx
maijin 10420 10403 1 03:11 ? 00:00:00 /opt/libreoffice5.0/program/soffice.bin --headless --invisible --convert-to pdf --outdir ./ ./55ffbc34c3808.docx
maijin 10427 8755 0 03:11 pts/1 00:00:00 grep libre
These processes never stop. I check the libreoffice and it is correct:
>ls -l /usr/local/bin/libreoffice5.0
lrwxrwxrwx 1 root root 35 Aug 22 02:54 /usr/local/bin/libreoffice5.0 -> /opt/libreoffice5.0/program/soffice
If I run the t.sh shell in linux console, the pdf file can be generated. Why can't I convert the doc to pdf in php?