Debian

沒有連接顯示器無法啟動 x11vnc

  • December 9, 2016

我想設置x11vnc(或任何其他 vnc 伺服器)在啟動時啟動。顯示管理器是kdm,發行版是 Ubuntu 12.04.2 LTS。

當我嘗試啟動 x11vnc 時,出現以下錯誤:

$ x11vnc -rfbauth /var/run/xauth/A:0-crWk72  -rfbport 5901
passing arg to libvncserver: -rfbauth
passing arg to libvncserver: /var/run/xauth/A:0-crWk72
passing arg to libvncserver: -rfbport
passing arg to libvncserver: 5901
x11vnc version: 0.9.12 lastmod: 2010-09-09  pid: 2828
XOpenDisplay("") failed.
Trying again with XAUTHLOCALHOSTNAME=localhost ...

*** XOpenDisplay failed. No -display or DISPLAY.
*** Trying ":0" in 4 seconds.  Press Ctrl-C to abort.
*** 1 2 3 4 
XOpenDisplay(":0") failed.
Trying again with XAUTHLOCALHOSTNAME=localhost ...
XOpenDisplay(":0") failed.
Trying again with unset XAUTHLOCALHOSTNAME ...

我已經嘗試安裝xserver-xorg-video-dummy以避免沒有連接螢幕的問題,但到目前為止沒有成功。

我想出了以下解決方案:

  1. sudo apt-get install x11vnc xserver-xorg-video-dummy
  2. 檢查/etc/default/grub它是否包含nomodeset標誌:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nomodeset" 3. 根據您的設置創建(或修改)/etc/X11/xorg.conf、修改USER和定址。LISTEN

Section "Monitor"
Identifier "Monitor0"
HorizSync 28.0-80.0
VertRefresh 48.0-75.0
# 1680x1050 @ 60.00 Hz (GTF) hsync: 65.22 kHz; pclk: 147.14 MHz
Modeline "1680x1050_60.00" 147.14 1680 1784 1968 2256 1050 1051 1054 1087 -HSync +Vsync
EndSection

Section "Device"
  Identifier "Card0"
  Driver "dummy"
  VideoRam 256000
EndSection

Section "Screen"
DefaultDepth 24
Identifier "Screen0"
Device "Card0"
Monitor "Monitor0"
    SubSection "Display"
    Depth 24
    Modes "1680x1050"    
    EndSubSection
EndSection

您可以生成自己的解析度

4 - 在中創建服務腳本/etc/init.d/vncserver

#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          vncserver
# Required-Start:    networking
# Default-Start:     3 4 5
# Default-Stop:      0 6
### END INIT INFO

PATH="$PATH:/usr/X11R6/bin/" CMD="/usr/bin/x11vnc"

# The Username:Group that will run VNC 
export USER="your_username"

# The display that VNC will use DISPLAY="1"

# Color depth (between 8 and 32) DEPTH="16"

# The Desktop geometry to use.
#GEOMETRY="<WIDTH>x<HEIGHT>"
#GEOMETRY="800x600" GEOMETRY="1680x1050"
#GEOMETRY="1280x1024"

# The name that the VNC Desktop will have. NAME="my-vnc-server"

PORT=5900 
LISTEN="192.168.1.10"


OPTIONS="-xkb -noxrecord -noxfixes -noxdamage -listen ${LISTEN} -name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY} -auth guess
-usepw ~/.vnc/passwd -rfbport ${PORT} -forever -bg -oa /var/log/x11vnc.log"

. /lib/lsb/init-functions

case "$1" in start) echo ${OPTIONS} log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}" su ${USER} -c "${CMD} ${OPTIONS}" ;;

stop) log_action_begin_msg "Stoping vncserver for user '${USER}' on localhost:${DISPLAY}" su ${USER} -c "${CMD} -kill :${DISPLAY}" ;;

restart) $0 stop $0 start ;; esac

exit 0

引用自:https://unix.stackexchange.com/questions/78103