无法以Web用户身份运行oowriter
我在笔记本电脑上设置了一个Web服务器.我正在构建一个可通过本地网络访问的Web应用程序. 我有一个包含以下行的php文件:
I have a web server set up on my laptop. I am building a web application which I am accessing through the local network. I have a php file which contains the following lines:
$command = "/usr/bin/oowriter --invisible --convert-to pdf /var/www/hackathon/document/gaurav.doc -outdir /var/www/hackathon/pdf/"
exec($command, $output, $return_var);
print_r($output);
所以,问题是当我在终端php中运行以上代码时,它运行得很好.但是,当通过Web浏览器访问时,输出只是空的,并且没有按预期完成转换.
So, the problem is that when I run the above code in the terminal php runs perfectly. But when accessed via a web browser, output is just empty and no conversion is done as intended.
Apache错误日志显示以下几行:
Apache error log shows the following lines:
[Java框架]函数createSettingsDocument(elements.cxx)中的错误.
javaldx失败!
警告:无法从javaldx读取路径
[Java framework] Error in function createSettingsDocument (elements.cxx).
javaldx failed!
Warning: failed to read path from javaldx
我尝试了 https://wiki.archlinux.org/index中的解决方案. php/Libreoffice#Fixing_Java_Framework_Error . 但这没用.
I have tried solutions from https://wiki.archlinux.org/index.php/Libreoffice#Fixing_Java_Framework_Error. But it didn't work.
我正在使用OpenJDK 7.
I am using OpenJDK 7.
有人对如何进行这项工作有任何想法吗?
Does anybody have any idea on how to make this work?
还不能投票,还不能评论...所以...
Can't vote, can't comment (yet)... So...
蒂姆·爱文(Tim-Erwin)说的是真的.
What Tim-Erwin said is true.
错误实际上表明函数createSettingsDocument中的错误,这提示某些名为createSettingsDocument的函数(注意:创建设置文档)失败了....
The error actually states that Error in function createSettingsDocument which is a hint that some function named createSettingsDocument (note: create Settings Document) is failing....
这就是您的方式(或至少是我)使其正常工作:
- 以普通用户身份运行一次libre office并记下目录 它创建的名称.
- 检查服务器正在运行的用户(或PHP正在运行的用户) 例如,如果您使用的是FPM等,则可能与www-data不同).
- 检查为此用户设置的主目录(从 /etc/passwd)
- 在第3步的目录中创建第1步中提到的目录
- 从步骤2将创建的目录的所有者更改为用户
- Run libre office as a normal user once and note the directory name it creates.
- Check which user the server is running (or which user PHP is running as, which might be different from www-data if you're on FPM etc...).
- Check what the home directory is set to for this user (from /etc/passwd for example)
- Create the directory noted in step 1 in the directory from step 3
- Change owner of created directory to the user from step 2
在我的服务器上,所需的目录实际上是/var/www/libreoffice ,而在我的台式机上,该目录将是/var/www/.config/libreoffice ,因此您需要确定.
On my server the needed directory was actually /var/www/libreoffice, while in my desktop machine,the directory would of been /var/www/.config/libreoffice so you need to make sure.