I have installed libreoffice headless on a freebsd-server with apache in order to convert documents programmatically (e.g. odt->pdf). It works from the command line! But my
This works for me.
Make sure you have installed java RE, for example in ubuntu:
apt-get install default-jre
First, find the location of your libreoffice
$ which libreoffice
/usr/bin/libreoffice
Include the folder location in the PATH, and also set the HOME var by adding these lines:
putenv('PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin');
putenv('HOME=/tmp');
system("libreoffice .....