# centos7配置vnc服务器

(adsbygoogle = window.adsbygoogle || []).push({});

目录

# 安装图形环境

$ yum groupinstall "X Window System"
$ yum install gnome-classic-session gnome-terminal nautilus-open-terminal control-center liberation-mono-fonts
$ reboot #重启机器

# 安装tigervnc-server

$ yum install tigervnc tigervnc-server

# 配置vncserver

$ cp /lib/systemd/system/[email protected] /etc/systemd/system/vncserver@:1.service

编辑/etc/systemd/system/vncserver@:1.service 修改<USER>为root,如下:

# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/sbin/runuser -l root -c "/usr/bin/vncserver %i"
PIDFile=/root/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

[Install]
WantedBy=multi-user.target

# 配置vnc访问密码

$ systemctl daemon-reload

配置密码

$ vncpasswd #设置vnc密码

设置开启启动

$ systemctl enable vncserver@:1.service #设置开机启动
$ systemctl start vncserver@:1.service #启动vnc会话服务
$ systemctl status vncserver@:1.service #查看nvc会话服务状态

关闭服务

$ systemctl stop vncserver@:1.service #关闭nvc会话服务
# netstat -lnt | grep 590*      #查看端口
Last Updated: 3/20/2023, 5:01:24 PM