我已经在带有 apache 的 freebsd-server 上安装了 libreoffice headless,以便以编程方式转换文档(例如 odt->pdf)。它从命令行工作!但我的目标是能够从 php 中做到这一点。这要求网络用户 (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
%
如果我尝试与 root 相同的命令,它不起作用。同样是来自 php 的 www-user 的问题:
sp# libreoffice --headless -convert-to pdf Litteraturundervisningogit.doc
javaPathHelper: not found
sp#
问题是我没有从 libreoffice 获得任何信息,因此我不知道为什么 libreoffice 不想以我自己以外的其他用户身份运行。
我的问题是:如何在 php 中通过 exec() 授予 www 用户运行 libreoffice 的权限?
最佳答案
在运行 convert 命令之前,我设法通过快速 export HOME=/tmp
解决了这个问题,这让 libreoffice 在某个地方可写以发挥它的魔力。
关于php - 从 php exec() 运行 libreoffice,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9056776/