解决CentOS下PHP system命令unoconv转PDF提示”Unable to connect or start own listener”

centos系统下,用php的system命令unoconv把word转pdf时提示Unable to connect or start own listene的解决办法

unoconv -o /foo/bar/public_html/upload/ -f pdf /foo/bar/public_html/upload/test.docx 2>&1
上面这个命令在shell 终端能执行成功,但是在php(Apache)中会报错:Unable to connect or start own listene

只需要先设置HOME变量即可:
passthru(‘export HOME=/foo/bar/public_html/upload/ && unoconv -o /foo/bar/public_html/upload/ -f pdf /foo/bar/public_html/upload/test.docx 2>&1’)