It was hard to find a resolution to this problem so I started some experiments.
There are no problems to run the unoconv from the console (to convert docx to pdf for example) but is hard when you try to run from PHP as an www-data user.
(process:350363): dconf-CRITICAL **: 10:28:43.201: unable to create directory ‘/var/www/.cache/dconf’: Permission denied. dconf will not work properly.
LibreOffice 6.4 – Fatal Error: The application cannot be started.
User installation could not be completed.
Error: Unable to connect or start own listener. Aborting.
The first-row show that can’t your current user can’t create a folder i the path /var/www/. What a surprise! In Ubuntu linux this is the home folder of the www-data user by default and by default, the permission is set to root:root. I suppose it’s for some security reason. The thing you can do is to create 2 folders, which are required from unoconv to work – .cache and .config (and set the required permissions).
sudo mkdir .cache sudo chown -R www-data:www-data .cache/ sudo chmod -R 744 .cache/ sudo mkdir .config sudo chown -R www-data:www-data .config/ sudo chmod -R 744 .config/
Et voila. Your unoconv cant write cache and config so should work
P.S. To check your www-data $HOME
sudo cat /etc/passwd | grep www-data www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
command = 'unoconv -f pdf ' . $path.$file; command, $output);