本文小编为大家详细介绍“Centos中怎么安装vncserver”,内容详细,步骤清晰,细节处理妥当,希望这篇“Centos中怎么安装vncserver”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。
VNC (Virtual Network Console)是虚拟网络控制台的缩写。它是一款优秀的远程控制工具软件,由著名的 AT&T 的欧洲研究实验室开发的。VNC 是在基于 UNIX 和 Linux 操作系统的免费的开源软件,远程控制能力强大,高效实用,其性能可以和 Windows 和 MAC 中的任何远程控制软件媲美。
本实验中安装的系统没有安装桌面环境,我们需要自己安装,如果已经安装桌面了清跳过这一步。Centos7提供了”Cinnamon Desktop”,”MATE Desktop”,”GNOME Desktop”,”KDE Plasma Workspaces”,”LXQt Desktop”,”Xfce”让我们安装。
下面的命令列出可用环境组:
[root@localhost ~]# yum grouplistLoaded plugins: fastestmirror There is no installed groups file. Maybe run: yum groups mark convert (see man yum) Loading mirror speeds from cached hostfile * base: mirrors.tuna.tsinghua.edu.cn * epel: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Available Environment Groups: Minimal Install Compute Node Infrastructure Server File and Print Server Cinnamon Desktop MATE Desktop Basic Web Server Virtualization Host Server with GUI GNOME Desktop KDE Plasma Workspaces Development and Creative Workstation Available Groups: Cinnamon Compatibility Libraries Console Internet Tools Development Tools Educational Software Electronic Lab Fedora Packager General Purpose Desktop Graphical Administration Tools Haskell LXQt Desktop Legacy UNIX Compatibility MATE Milkymist Scientific Support Security Tools Smart Card Support System Administration Tools System Management TurboGears application framework Xfce Done
我们可以选择自己喜欢的桌面环境,在这里选择安装Xfce桌面:
[root@localhost ~]# yum -y install epel-release && yum groupinstall Xfce
创建一个用户
[root@localhost ~]# useradd user1[root@localhost ~]# echo '123456'|passwd --stdin user1[root@localhost ~]# usermod -a -G wheel user1
在Centos仓库默认提供的是TigerVNC安装包,我们就安装这个:
[root@localhost ~]# yum -y install tigervnc-server tigervnc-server-module
切换到user1用户,运行vncserver命令创建一个初始配置并设置密码:
[root@localhost ~]# su - user1[user1@localhost ~]$ vncserver :2 You will require a password to access your desktops. Password: Verify: Would you like to enter a view-only password (y/n)? n A view-only password is not used New 'localhost.localdomain:2 (user1)' desktop is localhost.localdomain:2 Starting applications specified in /home/user1/.vnc/xstartup Log file is /home/user1/.vnc/localhost.localdomain:2.log
然后停止vncserver服务,目的就是创建密码和.vnc下面的文件。
[user1@localhost ~]$ vncserver -kill :2
编辑用户家目录下面的.vnc/xstartup文件
[user1@localhost ~]$ vim ~/.vnc/xstartup#!/bin/shxrdb $HOME/.Xresources#xsetroot -solid grey#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &#twm &startxfce4 &
如果需要修改屏幕分辨率,可以修改~/.vnc/config文件,取消gemoetry前面的注释。
[user1@localhost ~]$ vim .vnc/config## Supported server options to pass to vncserver upon invocation can be listed## in this file. See the following manpages for more: vncserver(1) Xvnc(1).## Several common ones are shown below. Uncomment and modify to your liking.### securitytypes=vncauth,tlsvnc# desktop=sandboxgeometry=1920x1080# localhost# alwaysshared
Unit文件方便快速的启动,停止,重启服务
[user1@localhost ~]$ sudo cp /usr/lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:2.service
编辑vncserver@:2.service,替换文件里面的为user1用户, Type由默认的forking改为simple
[user1@localhost ~]$ vim /etc/systemd/system/vncserver\@\:2.service [Unit] Description=Remote desktop service (VNC) After=syslog.target network.target [Service] Type=simple ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'ExecStart=/usr/sbin/runuser -l user1 -c "/usr/bin/vncserver %i"PIDFile=/home/user1/.vnc/%H%i.pid ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'[Install] WantedBy=multi-user.target
启动vncserver服务
#重新加载管理器配置[user1@localhost ~]$ sudo systemctl daemon-reload#启动vncserver[user1@localhost ~]$ sudo systemctl start vncserver@:2
客户端远程连接测试
在windows10客户端打开VNC Viewer,输入地址和会话端口号:
读到这里,这篇“Centos中怎么安装vncserver”文章已经介绍完毕,想要掌握这篇文章的知识点还需要大家自己动手实践使用过才能领会,如果想了解更多相关内容的文章,欢迎关注亿速云行业资讯频道。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。