Centos 7 安裝VNC步驟

2021-09-29 18:36:46 字數 2984 閱讀 4126

先囉嗦一下vnc是什麼( 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

如果報:

centos7 vnc報vncserver@:1.service:control process exited,code-exited status=98

修改type為

type=******

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

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

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

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

Centos 7 安裝VNC步驟

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

Centos 7 安裝VNC步驟

分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!centos7 安裝vnc步驟 一.安裝 1.以root使用者執行以下命令來安裝vncserver yum install tigervnc server 2.同樣執行以下命令來安裝vncviewer yum install vnc 3.停止並禁用...

centos7 安裝vnc服務

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