从php exec()运行libreoffice

use*_*941 13 php permissions exec libreoffice

我已经在带有apache的freebsd-server上安装了libreoffice headless,以便以编程方式转换文档(例如odt-> pdf).它从命令行工作!但我的目标是能够从PHP做到这一点.这要求web用户(www)可以运行libreoffice.但它不能.

当我自己的用户运行libreoffice时,我得到:

%libreoffice --headless -convert-to pdf Litteraturundervisningogit.doc
javaPathHelper: not found #This should not be a problem, says people on the net.
convert /usr/home/bundsgaard.net/www/jeppe/foredrag/Litteraturundervisningogit.doc ->
 /usr/home/bundsgaard.net/www/jeppe/foredrag/Litteraturundervisningogit.pdf using writer_pdf_Export
%
Run Code Online (Sandbox Code Playgroud)

如果我尝试与root相同的命令,它不起作用.同样是来自php的www-user的问题:

sp# libreoffice --headless -convert-to pdf Litteraturundervisningogit.doc
javaPathHelper: not found
sp#
Run Code Online (Sandbox Code Playgroud)

问题是我没有从libreoffice获得任何信息,因此我不知道为什么libreoffice不想像其他用户那样运行.

我的问题是:如何通过php中的exec()授予www-user权限来运行libreoffice?

Que*_*ark 14

我设法export HOME=/tmp在运行convert命令之前快速解决了这个问题,这使得libreoffice可以在某个地方写入来实现它的魔力.


Mar*_*ker 3

严格来说这不是一个答案,但您可以考虑使用PUNO,一个 PHP5 模块,它提供对 OpenOffice.org UNO 编程 API 的访问,而不是使用 PHP 的 exec。