centos7 安装vnc服务端

一、安装图形界面

#1.安装图形用户界面接口X Window System
yum groupinstall "X Window System"
#2.卸载命令
yum groupremove "X Window System"
#3.安装图形用界面gnome
yum groupinstall "GNOME Desktop"
#4.卸载命令
yum groupremove "GNOME Desktop"

二、vnc服务端安装

#1.安装tigervnc-server
[root@kht118 ~]# yum install -y tigervnc-server
#2.查看对应的安装服务
[root@kht118 ~]# rpm -qa|grep tigervnc-server
tigervnc-server-minimal-1.8.0-22.el7.x86_64
tigervnc-server-1.8.0-22.el7.x86_64
#3.复制文件
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
#4.修改复制后的文件
cd /etc/systemd/system/
vim vncserver@:1.service
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=forking

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

[Install]
WantedBy=multi-user.target

#5.重新加载配置文件
[root@kht118 system]# systemctl daemon-reload
#6.设置密码
[root@kht118 system]# vncpasswd
Password:
Verify:
Would you like to enter a view-only password (y/n)? n
A view-only password is not used
#7.启动
[root@kht118 system]# systemctl start vncserver@:1.service
#8.查看端口
[root@kht118 system]# netstat -ltp|grep Xvnc
tcp        0      0 0.0.0.0:5901            0.0.0.0:*               LISTEN      11800/Xvnc
tcp        0      0 0.0.0.0:6001            0.0.0.0:*               LISTEN      11800/Xvnc
tcp6       0      0 [::]:5901               [::]:*                  LISTEN      11800/Xvnc
tcp6       0      0 [::]:6001               [::]:*                  LISTEN      11800/Xvnc
#9.查看状态
[root@kht118 system]# systemctl status vncserver@:1.service
#10.设置为自动启动
[root@kht118 system]# systemctl enable vncserver@:1.service

三、使用VNC Viewer连接(有时候需要reboot一下)

下载网站


四、其他命令

vncserver -list
#开启
vncserver

五、其它工具未测试

参考

posted @ 2023-01-09 14:00  kht  阅读(770)  评论(0编辑  收藏  举报