cnetos7 vnc server安装与配置

一、安装

1,查看是否安装

[root@localhost ~]# rpm -qa |grep vnc
gvnc-0.5.2-7.el7.x86_64
tigervnc-server-minimal-1.3.1-4.el7_2.x86_64
gtk-vnc2-0.5.2-7.el7.x86_64
tigervnc-license-1.3.1-4.el7_2.noarch
tigervnc-server-minimal-1.3.1-3.el7.x86_64
tigervnc-license-1.3.1-3.el7.noarch
libvncserver-0.9.9-9.el7_0.1.x86_6

2,若未安装使用yum安装

[root@localhost ~]# yum installtigervnc-server tigervnc-server-module

3,关闭防火墙

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

二、配置

1copy配置文件

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


若出现cannot stat ‘/lib/systemd/system/[email protected]’: No such fileor directory重新yum安装即可

2,修改配置文件

[root@localhost ~]# vim /etc/systemd/system/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 %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 || :'

#这里使用root用户,将换成rootPIDFile路径注意去掉/home/

3,开机启动服务

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


4,配置登录密码

[root@localhost ~]# vncpasswd

5,启动服务

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


6,查看监听接口

[root@localhost ~]# netstat -nat | grep 590*
tcp       0    0 0.0.0.0:5901     0.0.0.0:*     LISTEN    
tcp6      0    0 :::5901      :::*       LISTEN

 

7,查看排错日志

[root@localhost ~]# grep vnc/var/log/messages

8,登录

cnetos7 vncserver安装与配置_第1张图片