Centos 7 安裝VNC步驟

來源:互聯網
上載者:User

標籤:

先囉嗦一下VNC是什麼( Virtual Network Computing)VNC允許Linux系統可以類似實現像Windows中的遠端桌面訪問那樣訪問Linux案頭。本文配置機器是興寧市網路資訊中心的一台Centos 7 HP伺服器環境下運行。

首先試試伺服器裝了VNC沒

[[email protected] ~]# rpm -q tigervnc tigervnc-server

沒安裝的話會直接出現

package tigervnc is not installedpackage tigervnc-server is not installed

如果沒有安裝X-Windows 案頭的話要先安裝Xwindows

[[email protected] ~]# yum check-update[[email protected] ~]# yum groupinstall "X Window System"[[email protected] ~]# yum install gnome-classic-session gnome-terminal nautilus-open-terminal control-center liberation-mono-fonts[[email protected] ~]# unlink /etc/systemd/system/default.target[[email protected] ~]# ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target[[email protected] ~]# reboot

第一步,安裝VNC packages:

[[email protected] ~]# yum install tigervnc-server -y

第二步,修改配置資訊,在/etc/systemd/system/下建立檔案夾[email protected]:1.service 把example config 檔案從/lib/systemd/system/[email protected]複製到裡面

[[email protected] ~]# cp /lib/systemd/system/[email protected] /etc/systemd/system/[email protected]:1.service

然後開啟這個設定檔/etc/systemd/system/[email protected]:1.service替換掉預設使用者名

找到這一行

ExecStart=/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"PIDFile=/home/<USER>/.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

[[email protected] ~]# systemctl daemon-reload

第四步,為VNC設密碼

[[email protected] ~]# 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 預設防火牆的可能需要

[[email protected] ~]# firewall-cmd --permanent --add-service vnc-server[[email protected] ~]# systemctl restart firewalld.service

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

[[email protected] ~]# systemctl enable [email protected]:1.service[[email protected] ~]# systemctl start [email protected]:1.service

這樣基本上Centos 端就設好了,Windows 端要去下一個VNC Viewer 的軟體。串連一下試試看著有點簡陋但是上去了的


Centos 7 安裝VNC步驟

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.