前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >CentOS7.3下部署TigerVNC Server过程详解

CentOS7.3下部署TigerVNC Server过程详解

原创
作者头像
好派笔记
修改2021-09-16 10:41:19
1.3K1
修改2021-09-16 10:41:19
举报
文章被收录于专栏:好派笔记好派笔记

关于TigerVNC Server的安装,可以直接使用本地yum源进行安装,安装前需要做一下准备工作,安装完成后需要配置,具体如下:

1.关闭防火墙

centos的防火墙是firewalld

  1. [root@haopython ~]# systemctl stop firewalld.service  #停止firewall
  2. [root@haopython ~]# systemctl disable firewalld.service  #禁止firewall开机启动
  3. [root@haopython ~]# 

2.关闭SELinux

  1. [root@haopython ~]# setenforce 0 #设置SELinux 成为permissive模式 临时关闭selinux
  2. [root@haopython ~]# getenforce
  3. Permissive  #宽容模式
  4. [root@haopython ~]# cat /etc/sysconfig/selinux
  5. SELINUX=disabled  
  6. SELINUXTYPE=targeted  
  7. [root@haopython ~]# 

3.安装VNC软件

  1. [root@haopython ~]# yum install tigervnc-server tigervnc vnc vnc-server

4.配置VNC连接

1)备份配置文件

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

其中 vncserver@:1.service 对应的端口是5901如果是2,那端口则是5902

2)编辑复制的新文件

  1. [root@haopython ~]# vi /etc/systemd/system/vncserver@:1.service
  2. [root@haopython ~]# 

找到下面部分进行修改,以root用户登录:

  1. [Service]  
  2. Type=forking  
  3. # Clean any existing files in /tmp/.X11-unix environment
  4. ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'  
  5. ExecStart=/usr/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"  
  6. PIDFile=/home/<USER>/.vnc/%H%i.pid  
  7. ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'  
  8. [Install]  
  9. WantedBy=multi-user.target  

改成:

  1. ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'  
  2. ExecStart=/usr/sbin/runuser -l root -c "/usr/bin/vncserver %i"  
  3. PIDFile=/root/.vnc/%H%i.pid  
  4. ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'  
  5. [Install]  
  6. WantedBy=multi-user.target  

3)设置VNC密码

  1. [root@haopython ~]# vncpasswd
  2. Password:123456  
  3. Verify:123456  

5.启动VNC

  1. [root@haopython ~]# systemctl daemon-reload #重启daemon使上述配置生效
  2. [root@haopython ~]# systemctl enable vncserver@:1.service #使服务自动启动
  3. [root@haopython ~]# systemctl start vncserver@:1.service #启动服务
  4. Job for vncserver@:1.service failed because a configured resource limit was exceeded. See "systemctl status vncserver@:1.service" and "journalctl -xe" for details.  

以上出错的解决办法: 删除/tmp/.X11-unix/ 目录,再启用一次即可

  1. [root@haopython ~]# rm -f -R /tmp/.X11-unix/

然后重启VNC

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

6.测试VNC连接

CentOS7.3下部署TigerVNC Server过程详解
CentOS7.3下部署TigerVNC Server过程详解

用VNC view登录测试

7.其他补充

1)重设VNC密码

  1. [root@haopython ~]# vncpasswd
  2. Password:  
  3. Verify:  
  4. Would you like to enter a view-only password (y/n)? n  
  5. A view-only password is not used  
  6. [root@haopython ~]# 

2)查看VNC状态

  1. [root@haopython ~]# systemctl status vncserver@:1.service
  2. ● vncserver@:1.service - Remote desktop service (VNC)  
  3.    Loaded: loaded (/etc/systemd/system/vncserver@:1.service; enabled; vendor preset: disabled)  
  4.    Active: active (running) since Fri 2018-05-18 13:04:53 CST; 31s ago  
  5.   Process: 1181 ExecStart=/usr/sbin/runuser -l root -c /usr/bin/vncserver %i (code=exited, status=0/SUCCESS)  
  6.   Process: 1117 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)  
  7.  Main PID: 3562 (Xvnc)  
  8.    CGroup: /system.slice/system-vncserver.slice/vncserver@:1.service  
  9.            ? 3562 /usr/bin/Xvnc :1 -auth /root/.Xauthority -desktop haopython.com:1 (root) -fp catalogue:...  
  10. May 18 13:04:43 haopython.com systemd[1]: Starting Remote desktop service (VNC)...  
  11. May 18 13:04:53 haopython.com systemd[1]: Started Remote desktop service (VNC).  
  12. [root@haopython ~]# 

3)kill vncserver

  1. [root@haopython ~]# vncserver -kill :1
  2. Killing Xvnc process ID 3562  
  3. [root@haopython ~]# 

4)启动VNC

  1. [root@haopython ~]# vncserver :1
  2. New 'haopython.com:1 (root)' desktop is haopython.com:1  
  3. Starting applications specified in /root/.vnc/xstartup  
  4. Log file is /root/.vnc/haopython.com:1.log  
  5. [root@haopython ~]# 

5)卸载VNC

  1. [root@haopython ~]# yum remove tigervnc-server

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1.关闭防火墙
  • 2.关闭SELinux
  • 3.安装VNC软件
  • 4.配置VNC连接
  • 1)备份配置文件
  • 2)编辑复制的新文件
  • 3)设置VNC密码
  • 5.启动VNC
  • 6.测试VNC连接
  • 7.其他补充
  • 1)重设VNC密码
  • 2)查看VNC状态
  • 3)kill vncserver
  • 4)启动VNC
  • 5)卸载VNC
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档