unable to run oowriter as web user

会有一股神秘感。 提交于 2019-12-01 15:43:51

Can't vote, can't comment (yet)... So...

What Tim-Erwin said is true.

The error actually states that Error in function createSettingsDocument which is a hint that some function named createSettingsDocument (note: create Settings Document) is failing....

Here's how you (or atleast I) get it to work:

  1. Run libre office as a normal user once and note the directory name it creates.
  2. 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...).
  3. Check what the home directory is set to for this user (from /etc/passwd for example)
  4. Create the directory noted in step 1 in the directory from step 3
  5. Change owner of created directory to the user from step 2

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.

Fraber's answer solved the problem for me!

Used:

$cmd = 'HOME='.getCWD().' && export HOME && libreoffice --headless ....';
exec($cmd);

libreoffice then created '.config' and 'libreoffice' directories in the php script directory. Obviously it must be writeable by the webserver process.

OpenOffice needs a user directory. Since you are trying to invoke OpenOffice with the web server, you have to grant the respective user write access to is. On Debian, for instance, that would mean to allow www-data to write to /var/www/.openoffice.org/:

mkdir /var/www/.openoffice.org
chown www-data /var/www/.openoffice.org

I got the same error message running "ooffice --headless --convert-to pptx filename" from a Web server (actually "NaviServer" 4.99). The solutions above did not solve my issue, but they got me on the right track. It turned out that NaviServer changes the "HOME" environment variable to it's installation directory /usr/local/ns, so that LibreOffice tried to access and create a .config folder in this directory. I found out by executing the BASH "set" command from the Web server and checking the environment variables.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!