溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Centos中怎么安裝vncserver

發(fā)布時(shí)間:2022-02-17 09:23:02 來源:億速云 閱讀:456 作者:iii 欄目:開發(fā)技術(shù)

本文小編為大家詳細(xì)介紹“Centos中怎么安裝vncserver”,內(nèi)容詳細(xì),步驟清晰,細(xì)節(jié)處理妥當(dāng),希望這篇“Centos中怎么安裝vncserver”文章能幫助大家解決疑惑,下面跟著小編的思路慢慢深入,一起來學(xué)習(xí)新知識吧。

VNC (Virtual Network Console)是虛擬網(wǎng)絡(luò)控制臺的縮寫。它是一款優(yōu)秀的遠(yuǎn)程控制工具軟件,由著名的 AT&T 的歐洲研究實(shí)驗(yàn)室開發(fā)的。VNC 是在基于 UNIX 和 Linux 操作系統(tǒng)的免費(fèi)的開源軟件,遠(yuǎn)程控制能力強(qiáng)大,高效實(shí)用,其性能可以和 Windows 和 MAC 中的任何遠(yuǎn)程控制軟件媲美。

Centos中怎么安裝vncserver

系統(tǒng)環(huán)境

  • 服務(wù)端:Centos7.7 Minimal
  • 客戶端:Windows10

安裝桌面環(huán)境

本實(shí)驗(yàn)中安裝的系統(tǒng)沒有安裝桌面環(huán)境,我們需要自己安裝,如果已經(jīng)安裝桌面了清跳過這一步。Centos7提供了”Cinnamon Desktop”,”MATE Desktop”,”GNOME Desktop”,”KDE Plasma Workspaces”,”LXQt Desktop”,”Xfce”讓我們安裝。

下面的命令列出可用環(huán)境組:

[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

我們可以選擇自己喜歡的桌面環(huán)境,在這里選擇安裝Xfce桌面:

[root@localhost ~]# yum -y install epel-release && yum groupinstall Xfce

創(chuàng)建一個(gè)用戶

[root@localhost ~]# useradd user1[root@localhost ~]# echo '123456'|passwd --stdin user1[root@localhost ~]# usermod -a -G wheel user1

安裝VNC Server

在Centos倉庫默認(rèn)提供的是TigerVNC安裝包,我們就安裝這個(gè):

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

切換到user1用戶,運(yùn)行vncserver命令創(chuàng)建一個(gè)初始配置并設(shè)置密碼:

[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服務(wù),目的就是創(chuàng)建密碼和.vnc下面的文件。

[user1@localhost ~]$ vncserver -kill :2

配置VNC Server

編輯用戶家目錄下面的.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

創(chuàng)建 Systemd Unit文件

Unit文件方便快速的啟動,停止,重啟服務(wù)

[user1@localhost ~]$ sudo cp /usr/lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:2.service

編輯vncserver@:2.service,替換文件里面的為user1用戶, Type由默認(rèn)的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服務(wù)

#重新加載管理器配置[user1@localhost ~]$ sudo systemctl daemon-reload#啟動vncserver[user1@localhost ~]$ sudo systemctl start vncserver@:2

客戶端遠(yuǎn)程連接測試

在windows10客戶端打開VNC Viewer,輸入地址和會話端口號:
Centos中怎么安裝vncserver

讀到這里,這篇“Centos中怎么安裝vncserver”文章已經(jīng)介紹完畢,想要掌握這篇文章的知識點(diǎn)還需要大家自己動手實(shí)踐使用過才能領(lǐng)會,如果想了解更多相關(guān)內(nèi)容的文章,歡迎關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI