Skip to content

Unoconv and www-data permissions problem. Solved for me

The problem

It was hard to find a resolution to this problem so I started some experiments.

There are no problems running the unoconv from the console (to convert docx to pdf for example) but is hard when you try to run from PHP as a 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 shows that can’t your current user can’t create a folder i the path /var/www/.

The solution

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

example command

$command = 'unoconv -f pdf ' . $path.$file;
exec($command, $output);

Update: Unoconv is deprecated

read more on git:

Please note that there is a rewrite of Unoconv called “Unoserver”:

Visits: 727

Leave a Reply

Your email address will not be published. Required fields are marked *