Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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]$
share|improve this question
    
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
show 15 more comments

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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