您好,登錄后才能下訂單哦!
本文小編為大家詳細介紹“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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。