The problem of php running libreoffice to convert word file to pdf?

segmentfault 2022-08-06 18:38:43 阅读数:820


Running libreoffice in the liunx control panel to execute word to pdf is successful!
But using php to execute the libreoffice statement will report a 504 error, please give me some pointers?

The code is as follows:

$status = 1;
$strss = "export HOME=/tmp/ && /usr/bin/libreoffice --headless --convert-to pdf:writer_pdf_Export /www/wwwroot/doctor-link/public/contract/report.docx --outdir /www/wwwroot/doctor-link/public/contract/";
exec($strss, $log, $status);

Execution under liunx alone is successful:
export HOME=/tmp/ && /usr/bin/libreoffice --headless --convert-to pdf:writer_pdf_Export /www/wwwroot/doctor-link/public/contract/report.docx --outdir /www/wwwroot/doctor-link/public/contract/

Other Answer 1:

You said that using php to execute the error 504 is to execute the php script directly on linux, or to execute your php code in other ways;
After the error is reported, you can try to disassemble the command and locate the specific oneerror affected.