將VNC 安裝在Centos 7步驟

2021-07-07 08:39:28 字數 2852 閱讀 5420

( virtual network computing)vnc允許linux系統可以類似實現像windows中的遠端桌面訪問那樣訪問linux桌面。本文配置機器是興寧市網路資訊中心的一台centos 7 hp伺服器環境下執行。

首先試試伺服器裝了vnc沒

[root@wic ~]# rpm -q tigervnc tigervnc-server
沒安裝的話會直接出現

package tigervnc is not installed

package tigervnc-server is not installed

如果沒有安裝x-windows 桌面的話要先安裝xwindows

[root@wic ~]# yum check-update

[root@wic ~]# yum groupinstall "x window system"

[root@wic ~]# yum install gnome-classic-session gnome-terminal nautilus-open-terminal control-center liberation-mono-fonts

[root@wic ~]# unlink /etc/systemd/system/default.target

[root@wic ~]# ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target

[root@wic ~]# reboot

第一步,安裝vnc packages:

[root@wic ~]# yum install tigervnc-server -y
第二步,修改配置資訊,在/etc/systemd/system/下建立資料夾vncserver@:1.service 把example config 檔案從/lib/systemd/system/[email protected]複製到裡面

[root@wic ~]# cp /lib/systemd/system/[email protected] /etc/systemd/system/vncserver@:1.service
然後開啟這個配置檔案/etc/systemd/system/vncserver@:1.service替換掉預設使用者名稱

找到這一行

execstart=/sbin/runuser -l -c "/usr/bin/vncserver %i"

pidfile=/home//.vnc/%h%i.pid

這裡我直接用root 使用者登入,所以我替換成

execstart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"

pidfile=/root/.vnc/%h%i.pid

如果是其他使用者的話比如linoxide替換如下

execstart=/sbin/runuser -l linoxide -c "/usr/bin/vncserver %i"

pidfile=/home/linoxide/.vnc/%h%i.pid

第三步,重載入 systemd

[root@wic ~]# systemctl daemon-reload
第四步,為vnc設密碼

[root@wic ~]# vncpasswd
第五步,由於我這邊的centos 7 是用iptable防火牆的所以

vim /etc/sysconfig/iptables
在合適位置加上

-a input -m state --state new -m tcp -p tcp --dport 5900:5903 -j accept
重啟iptable

service iptables restart
如果是用centos 7 預設防火牆的可能需要

[root@wic ~]# firewall-cmd --permanent --add-service vnc-server

[root@wic ~]# systemctl restart firewalld.service

如果還是有問題可以試試關閉防火牆

停止並禁用防火牆;

systemctl stop firewalld.service

systemctl disable firewalld.service

第六步,設預設啟動並開啟vnc

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

[root@wic ~]# systemctl start vncserver@:1.service

如果出現如下錯誤

job for vncserver@:1.service failed. see 『systemctl status vncserver@:1.service』 and 『journ 

alctl -xn』 for details.

把 vncserver@:1.service 中的 type 引數設定為 ****** 

再執行 systemctl daemon-reload和啟動開啟vnc

這樣基本上centos 端就設好了,windows 端要去下乙個vnc viewer 的軟體。連線一下試試看著有點簡陋但是上去了的

將VNC 安裝在Centos 7步驟

virtual network computing vnc允許linux系統可以類似實現像windows中的遠端桌面訪問那樣訪問linux桌面。本文配置機器是興寧市網路資訊中心的一台centos 7 hp伺服器環境下執行。首先試試伺服器裝了vnc沒 root wic rpm q tigervnc t...

Centos 7 安裝VNC步驟

先囉嗦一下vnc是什麼 virtual network computing vnc允許linux系統可以類似實現像windows中的遠端桌面訪問那樣訪問linux桌面。本文配置機器是興寧市網路資訊中心的一台centos 7 hp伺服器環境下執行。首先試試伺服器裝了vnc沒 root wic rpm ...

centos7 安裝vnc服務

一,安裝伺服器端 1,新增使用者 useradd vnc passwd vnc2,安裝gnome桌面 yum groupinstall gnome desktop unlink etc systemd system default.target ln sf lib systemd system gr...