Centos7 采用mini安装,如果想远程桌面,那就需要安装图形界面
# yum check-update # yum groupinstall "X Window System" # yum install gnome-classic-session gnome-terminal nautilus-open-terminal control-center liberation-mono-fonts # unlink /etc/systemd/system/default.target # ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target # reboot
Here begin the installation:
1, the installation tigervnc
# yum install tigervnc-server -y
2. Copy the files from the VNC service backup repository to the system directory service management service
# cp /lib/systemd/system/[email protected] /etc/systemd/system/vncserver@:1.service
3, modify the configuration file
# vim /etc/systemd/system/vncserver@:1.service
#改成root用户启动,配置文件看起来这样的
[Unit] Description=Remote desktop service (VNC) After=syslog.target network.target [Service] Type=forking 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
4, start the service
restart the process
# systemctl daemon-reload
Set VNC password
[root@local ~]# vncpasswd Password: Verify: Would you like to enter a view-only password (y/n)? n A view-only password is not used
Set boot and boot process
[root@local ~]# systemctl enable vncserver@:1.service Created symlink from /etc/systemd/system/multi-user.target.wants/vncserver@:1.service to /etc/systemd/system/vncserver@:1.service. [root@local ~]# systemctl start vncserver@:1.service [root@local ~]# systemctl status vncserver@:1.service ● vncserver@:1.service - Remote desktop service (VNC) Loaded: loaded (/etc/systemd/system/vncserver@:1.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2019-02-05 00:06:57 GMT; 7s ago Process: 58790 ExecStart=/usr/sbin/runuser -l root -c /usr/bin/vncserver %i (code=exited, status=0/SUCCESS) Process: 58778 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS) Main PID: 58831 (Xvnc) CGroup: /system.slice/system-vncserver.slice/vncserver@:1.service ‣ 58831 /usr/bin/Xvnc :1 -auth /root/.Xauthority -desktop cfl-lab.communit... Feb 05 00:06:53 cfl-lab.communityfibre.co.uk systemd[1]: Starting Remote desktop ser.... Feb 05 00:06:57 cfl-lab.communityfibre.co.uk systemd[1]: Started Remote desktop serv.... Hint: Some lines were ellipsized, use -l to show in full.
5, firewall settings,
turn off the firewall, or release port 5901.
6, VNC remote connections
now use VNC to remotely connected, VNC Server is there to fill in the <server IP address>: 5901