Failed to start oowriter as web user

I have a web server configured on my laptop. I am creating a web application that I access through a local network. I have a php file that 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); 

So the problem is that when running the above code in the php terminal it works fine. But when accessed via a web browser, the output is simply empty, and the conversion is not performed as intended.

The Apache error log shows the following lines:

[Java framework] Error in the createSettingsDocument (elements.cxx) function.
javaldx failed!
Warning: could not read the path from javaldx

I tried the solutions from https://wiki.archlinux.org/index.php/Libreoffice#Fixing_Java_Framework_Error . But that did not work.

I am using OpenJDK 7.

Does anyone have any ideas on how to make this work?

+8
ubuntu openjdk libreoffice
source share
4 answers

I can’t vote, I can’t comment (yet) ... So ...

What Tim Erwin said is true.

The error actually claims that the Error in the createSettingsDocument function , which is a hint that some function called createSettingsDocument (note: create a settings document) fails ....

Here, as you (or at least I) make it work:

  • Launch libre office as a regular user once and pay attention to the directory name that it creates.
  • Check which user is working on the server (or which PHP user is working as which may be different from www data if you are on FPM, etc.).
  • Check what the home directory for this user is installed for (from / etc / passwd, for example)
  • Create the directory specified in step 1 in the directory from step 3
  • Change the owner of the created directory to the user from step 2

On my server, the directory needed was actually / var / www / libreoffice , while on my desktop machine the directory was /var/www/.config/libreoffice , so you need to make sure.

+6
source share

OpenOffice needs a user directory. Since you are trying to call OpenOffice with a web server, you must provide the appropriate write access for the user. For example, in Debian, this would mean that www data can be written to /var/www/.openoffice.org/:

 mkdir /var/www/.openoffice.org chown www-data /var/www/.openoffice.org 
+3
source share

Answer Fraber solved the problem for me!

B:

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

libreoffice then created the .config and libreoffice directories in the php script directory. Obviously, it must be recorded in the web server process.

+3
source share

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

+1
source share

All Articles