2

I installed libreoffice.x86_64 using yum from the CentOS repository on my CentOS basic server. When running the following command from the shell, I get the following X11 error. xhost is installed on my box but X does not appear to be. What causes this error and how do I fix it?

[root@desktop ~]# HOME=/tmp/ayb; /usr/bin/libreoffice --headless -convert-to pdf --outdir /tmp/ayb /tmp/ayb/document_12.xlsx
/usr/lib64/libreoffice/program/soffice.bin X11 error: Can't open display:
   Set DISPLAY environment variable, use -display option
   or check permissions of your X-Server
   (See "man X" resp. "man xhost" for details)
[root@desktop ~]#

EDIT

Per comments, I did the following, and the error went away and the document was converted.

[root@desktop ~]# yum install tigervnc-server
[root@desktop ~]# vncserver :0
[root@desktop ~]# HOME=/tmp/ayb; /usr/bin/libreoffice -display :0 --headless -convert-to pdf --outdir /tmp/ayb /tmp/ayb/document_34.doc

My end goal is to use PHP through Apache to run this command. When attempting to do so, it isn't converted and I receive no error or feedback. I then tried to do the same command using a different user, but am having similar problems. Any suggestions?

-sh-4.1$ HOME=/tmp/ayb; /usr/bin/libreoffice -display :0 --headless -convert-to pdf --outdir /tmp/ayb /tmp/ayb/document_34.doc
No protocol specified
No protocol specified
/usr/lib64/libreoffice/program/soffice.bin X11 error: Can't open display: :0
   Set DISPLAY environment variable, use -display option
   or check permissions of your X-Server
   (See "man X" resp. "man xhost" for details)
-sh-4.1$

EDIT2

If I reboot server and do vncserver :0 under the other user, then try to convert the document, it just hangs indefinitely.

EDIT3

Tried the wizard both with and without setting display, but no good. Maybe some sort of permission problem?

[NotionCommotion@laptop root]$ HOME=/tmp/ayb; /usr/bin/libreoffice -display :0  --nofirststartwizard --headless -convert-to pdf --outdir /tmp/ayb /tmp/ayb/document_34.doc
/usr/lib64/libreoffice/program/soffice: line 68: cd: /root: Permission denied
No protocol specified
No protocol specified
/usr/lib64/libreoffice/program/soffice.bin X11 error: Can't open display: :0
   Set DISPLAY environment variable, use -display option
   or check permissions of your X-Server
   (See "man X" resp. "man xhost" for details)
[NotionCommotion@laptop root]$ HOME=/tmp/ayb; /usr/bin/libreoffice  --nofirststartwizard --headless -convert-to pdf --outdir /tmp/ayb /tmp/ayb/document_34.doc
/usr/lib64/libreoffice/program/soffice: line 68: cd: /root: Permission denied
/usr/lib64/libreoffice/program/soffice.bin X11 error: Can't open display:
   Set DISPLAY environment variable, use -display option
   or check permissions of your X-Server
   (See "man X" resp. "man xhost" for details)
[NotionCommotion@laptop root]$
  • Maybe the runtime switch -display :0? – Joseph Quinsey Jul 30 '13 at 13:43
  • libreoffice is clearly trying to contact your X server (which you seemed to indicate you don't have running) I assume that is why you were trying --headless. Either that wasn't the right flag or it doesn't work the way you expect (and still requires an X server to function). – Etan Reisner Jul 30 '13 at 13:46
  • @EtanReisner I've successfully used this on other servers, however, those other servers probably had gnome installed which might have installed X server. How do I tell if X server is installed and/or running? – user1032531 Jul 30 '13 at 13:54
  • @JosephQuinsey Like this? [root@desktop root]# HOME=/tmp/ayb; /usr/bin/libreoffice -display :0 --headless -convert-to pdf --outdir /tmp/ayb /tmp/ayb/document_12.xlsx /usr/lib64/libreoffice/program/soffice.bin X11 error: Can't open display: :0 Set DISPLAY environment variable, use -display option or check permissions of your X-Server (See "man X" resp. "man xhost" for details) – user1032531 Jul 30 '13 at 13:55
  • The idea of headless is that it eliminates the need for X - it isn't clear that this functionality is complete. Instead of installing all of X, I would install vncserver and run it as vncserver :0. Then export DISPLAY=:0 – Paul Jul 30 '13 at 13:55
8

This is an old one, but I ran into it myself today. the trick to using "--headless" is that you need to have libreoffice-headless installed (ie: yum install libreoffice-headless). not all libreoffice installs have libreoffice-headless installed - for example, mine today.

Found this nugget buried in the link user1032531 posted.

It would be nice if using --headless without the appropriate package generated an error to that effect, but it doesn't.

| improve this answer | |
-1

If you are going headless, then you shouldn't need X. See Convert file to PDF using LibreOffice under user apache (i.e. when using PHP) for a working solution.

| improve this answer | |
  • I got the same issue. The issue is easily reproducible: It works in the command line, but it doesn't work if I issue an "unset DISPLAY" before. So for some reason LibreOffice 5.1 does need a working X, even when running --headless. My command line: "exec /usr/bin/ooffice --headless --convert-to pptx /tmp/filecCn4GT.odp". Frank – fraber Mar 1 '16 at 18:04
-2

https://www.centos.org/forums/viewtopic.php?t=21514

yum install openoffice.org-headless
| improve this answer | |
  • Could you include some more information? Consider marking the yum line as code using four spaces or a tab to indent it. – Seth Dec 16 '16 at 11:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.