当前位置: 首页 > 工具软件 > VirtualGL > 使用案例 >

xubuntu16.04下安装turboVNC并设置开机自启(TurboVNC + VirtualGL)

齐夕
2023-12-01

关于TightVNC的安装和使用可参考:
在Ubuntu 16.04上安装和配置VNC
使用VNC过程中遇到的问题总结

  • 为什么使用TurboVNC?
    ——虽然TightVNC可以进行远程桌面登录,但如果运行有界面的软件或程序,无法显示界面且出现报错freeglut (Something): OpenGL GLX extension not supported by display ‘:1.0’,查了下好像是因为 TightVnc 不支持 GLX,需要使用TurboVNC + VirtualGL

1.安装TurboVNC和VirtualGL

TurboVNC下载地址https://www.turbovnc.org/
https://sourceforge.net/projects/turbovnc/files/

VirtualGL下载地址
https://sourceforge.net/projects/virtualgl/files/

下载TurboVNC + VirtualGL安装包:https://download.csdn.net/download/qq_45445740/87713640?spm=1001.2014.3001.5501
turbovnc-3.0.3-amd64.debvirtualgl-3.1-amd64.deb

  • 将TurboVNC + VirtualGL拷贝到目标设备上进行安装
sudo dpkg -i turbovnc-3.0.3-amd64.deb
sudo dpkg -i virtualgl-3.1-amd64.deb

安装完成可在 /opt/目录下查看

2.配置TurboVNC和VirtualGL

  • 配置 VirtualGL,终端输入 /opt/VirtualGL/bin/vglserver_config
[root@aubo]# /opt/VirtualGL/bin/vglserver_config

1) Configure server for use with VirtualGL
2) Unconfigure server for use with VirtualGL
X) Exit
 
Choose:
1
 
WARNING: Configuring this server for use with VirtualGL will disable the
ability to log in locally with a Wayland session.
 
Continue?
[Y/n]
Y
 
Restrict 3D X server access to vglusers group (recommended)?
[Y/n]
Y
 
Restrict framebuffer device access to vglusers group (recommended)?
[Y/n]
Y
 
Disable XTEST extension (recommended)?
[Y/n]
Y
  • 配置创建了一个新的用户组vglusers,在这个组里的成员才可使用VirtualGL,编辑/etc/group文件添加用户,最后一行改成如下:
vglusers:x:1001:root,aubo
  • 重启桌面环境或者重启设备
  • 配置TurboVNC
    TurboVNC的配置与一般的VNC软件相似,配置文件所在路径为/etc/turbovncserver.conf ,修改$useVGL的值为1,并取消注释
 # $wm = "";
 useVGL = 1;
 # $autokill = 1;

关于turbovncserver.conf配置文件,这是TurboVNC服务器的配置文件,用于配置VNC服务器的各种参数和选项。其中包括桌面分辨率、颜色深度、字体路径、安全类型、VNC用户目录、使用VGL等。用户可以根据需要取消注释并编辑这些选项,以满足自己的需求。此外,还可以设置VNC密码、X.509证书、X启动脚本等。

##
## Configuration of the TurboVNC Server.
##
## This file uses Perl syntax, although only one-line assignments
## are allowed.  Assignments can be applied to the following variables:
##
##  $geometry    -- desktop geometry, WIDTHxHEIGHT or
##                  W0xH0+X0+Y0[,W1xH1+X1+Y1,...,WnxHn+Xn+Yn]
##  $depth       -- color depth in bits per pixel (between 8 and 32)
##  $desktopName -- X desktop name
##  $vncUserDir  -- path to TurboVNC user directory (session information,
##                  VNC passwords, and log files are stored here)
##  $fontPath    -- X font path
##  $securityTypes -- comma-separated list of security types to enable
##                    (passed to Xvnc in the -securitytypes argument)
##  $generateOTP -- 1 to generate an initial one-time password.  (OTP
##                  authentication must be enabled and permitted)
##  $wm          -- the window manager to use (for instance, "mate" or "2d".)
##                  This variable is ignored if $xstartup or $noxstartup is
##                  specified.
##  $useVGL      -- 1 to run the window manager using VirtualGL.  This variable
##                  is ignored if $xstartup or $noxstartup is specified.
##  $autokill    -- 1 to automatically kill the TurboVNC session when the
##                  X startup script finishes or 0 to leave it running
##  $noVNC       -- directory containing noVNC
##  $passwdFile  -- path to VNC password file to use with VNC Password
##                  authentication
##  $x509CertFile -- path to X.509 signed certificate file (in PEM format) to
##                   use with X.509 encryption
##  $x509KeyFile -- path to X.509 private key file (in PEM format) to use with
##                  X.509 encryption
##  $xstartup    -- path to alternative X startup script
##  $noxstartup  -- 1 to start the TurboVNC session with no X startup script
##  $serverArgs  -- additional arguments to pass to Xvnc (refer to the Xvnc man
##                  page for a list of accepted arguments)
##

## These settings are the default.  Uncomment and edit to change.
#
# $geometry = "1240x900";
# $depth = 24;
$desktopName = "TurboVNC ($ENV{USER})";
# $vncUserDir = "$ENV{HOME}/.vnc";
# $fontPath = "";
# $securityTypes = "TLSVnc, TLSOtp, TLSPlain, X509Vnc, X509Otp, X509Plain, VNC, OTP, UnixLogin, Plain";
# $generateOTP = 0;
# $wm = "";
$useVGL = 1;
# $autokill = 1;
# $noVNC = "";
# $xstartup = "${exedir}xstartup.turbovnc";
# $noxstartup = 0;
# $serverArgs = "";

## Here is an example of setting the font path:
#
# $fontPath = "/usr/lib/X11/fonts/misc/"
# $fontPath = "$fontPath,/usr/lib/X11/fonts/75dpi/";

## You might wish to create the TurboVNC user directories under /tmp, to
## ensure that VNC passwords are always kept on the local filesystem.  To do
## that, uncomment the line below.  Note that in this case, Xvnc will search
## for the .Xauthority file in this same directory by default.
#
# $vncUserDir = "/tmp/$ENV{USER}-vnc";

## These settings are the default.  Uncomment and edit to change.
#
# $passwdFile = "$vncUserDir/passwd";
# $x509CertFile = "$vncUserDir/x509_cert.pem";
# $x509KeyFile = "$vncUserDir/x509_private.pem";

3.启动TurboVNC实例

  • 启动TurboVNC实例,终端输入:
/opt/TurboVNC/bin/vncserver :1
  • 启动后会在/root/.vnc目录下创建一个xstartup.turbovnc的文件,修改此文件的内容如下:(先生成文件,再去修改内容)
#!/bin/sh
 
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
#export VGL_DISPLAY=:1
#export DISPLAY=:1
/opt/VirtualGL/bin/vglrun -d :0 /usr/bin/startxfce4
  • 杀掉TurboVNC,再次启动TurboVNC实例
/opt/TurboVNC/bin/vncserver -kill :1

/opt/TurboVNC/bin/vncserver :1

4.设置TurboVNC自启动

  • 创建TurboVNC的systemd服务文件,turbovnc.service
sudo nano /etc/systemd/system/turbovnc.service
  • 在文件中输入以下内容:
[Unit]
Description=TurboVNC Server
After=syslog.target network.target

[Service]
Type=forking
User=root
Group=root
ExecStart=/opt/TurboVNC/bin/vncserver :1 -depth 24
ExecStop=/usr/bin/vncserver -kill :1

[Install]
WantedBy=multi-user.target
  • 1重新加载systemd配置文件
sudo systemctl daemon-reload
    1. 启用TurboVNC服务
sudo systemctl enable turbovnc.service
  1. 测试TurboVNC服务
sudo systemctl start turbovnc.service
  • 然后使用VNC客户端连接到TurboVNC服务器的IP地址和端口号(默认为5901),输入VNC密码即可。
    1. 验证TurboVNC服务是否已经开机自启动
sudo systemctl status turbovnc.service

如果服务已经开机自启动,则输出的信息中应该包含“Loaded: loaded (/etc/systemd/system/turbovnc.service; enabled; vendor preset: enabled)”这一行。

turboVNC启动后,通过ps -aux | grep Xvnc查看服务是否已启动

参考:
https://www.xiexianbin.cn/linux/vnc/turbovnc/index.html
https://blog.csdn.net/weixin_44831881/article/details/119810165

 类似资料: