centos配置图形化桌面以及vnc安装配置

以centos 7.4为例,安装配置vnc

1)关闭防火墙和SELinux

[root@localhost ~]# systemctl stop firewalld.service

[root@localhost ~]# systemctl stop iptables.service

[root@localhost ~]# setenforce 0

[root@localhost ~]# getenforce

[root@localhost ~]# cat /etc/sysconfig/selinux SELINUX=disabledSELINUXTYPE=targeted


2)安装软件

[root@localhost ~]# yum groupinstall “GNOME Desktop” “X Window System” “Desktop”

[root@localhost ~]# yum install tigervnc-server tigervnc vnc vnc-server

3)配置vnc连接

[root@localhost ~]# cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service

[root@localhost ~]#vim /etc/systemd/system/vncserver@:1.service找到这一行ExecStart=/sbin/runuser -l <USER> -c “/usr/bin/vncserver %i”PIDFile=/home/<USER>/.vnc/%H%i.pid这里直接用root 用户登录,所以替换成ExecStart=/sbin/runuser -l root -c “/usr/bin/vncserver %i”PIDFile=/root/.vnc/%H%i.pid如果是其他用户的话比如john替换如下ExecStart=/sbin/runuser -l john -c “/usr/bin/vncserver %i”PIDFile=/home/john/.vnc/%H%i.pid为VNC设密码

[root@localhost ~]# vncpasswd123456

[root@localhost ~]# vim /etc/libvirt/qemu.conf 找到下面语句,删除注释符号#,并修改如下vnc_password = “123456”vnc_listen = “0.0.0.0”

[root@localhost ~]# systemctl daemon-reload


3)配置vnc连接

[root@localhost ~]# cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service

[root@localhost ~]#vim /etc/systemd/system/vncserver@:1.service找到这一行ExecStart=/sbin/runuser -l <USER> -c “/usr/bin/vncserver %i”PIDFile=/home/<USER>/.vnc/%H%i.pid这里直接用root 用户登录,所以替换成ExecStart=/sbin/runuser -l root -c “/usr/bin/vncserver %i”PIDFile=/root/.vnc/%H%i.pid如果是其他用户的话比如john替换如下ExecStart=/sbin/runuser -l john -c “/usr/bin/vncserver %i”PIDFile=/home/john/.vnc/%H%i.pid为VNC设密码

[root@localhost ~]# vncpasswd123456

[root@localhost ~]# vim /etc/libvirt/qemu.conf 找到下面语句,删除注释符号#,并修改如下vnc_password = “123456”vnc_listen = “0.0.0.0”

[root@localhost ~]# systemctl daemon-reload

4)启动vnc

[root@localhost ~]# systemctl start vncserver@:1.service


5)测试vnc本地安装vnc客户端输入主机ip:5901进行测试