在Centos 7上安裝VNC server

來源:互聯網
上載者:User

標籤:centos 7 vnc server

VNC是個比較不錯的遠程工具,無論基於Windows平台或Linux平台,由於最近在學習Centos的相關知識,所以準備在Centos 7上搭建一個VNC server便於我從用戶端機器通過VNC viewer來遠端連線操作。

如果你沒有安裝案頭環境(X Windows),可以使用以下命令來安裝,大概花費幾分鐘時間來安裝此packages.

[[email protected] ~]# yum check-update[[email protected] ~]# yum groupinstall "X Windows 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

重啟後就可以進入到Centos 7的案頭環境了。

Step 1 輸入以下命令安裝VNC 包

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

Step 2 在/etc/systemd/system/目錄建立一個檔案[email protected]:1.service,並複製執行個體設定檔/lib/systemd/system/[email protected]至其中

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

Step 3 開啟並編輯/etc/systemd/system/[email protected]:1.service檔案並用你自己的使用者名稱取代其中的user項

[Service]Type=forking# Clean any existing files in /tmp/.X11-unix environmentExecStartPre=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :‘ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"PIDFile=/root/.vnc/%H%i.pid

注意如上root,我所使用的是root帳號登陸,所以將<user>更改為root

Step 4 重啟systemd

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

Step 5 為使用者建立VNC密碼

[[email protected] system]# vncpasswd

此處我建立密碼為123456

Step 6 啟用並啟動服務

[[email protected] system]# systemctl enable [email protected]:1.serviceln -s ‘/etc/systemd/system/[email protected]:1.service‘ ‘/etc/systemd/system/multi-user.target.wants/[email protected]:1.service‘[[email protected] system]# systemctl start vn[email protected]:1.service

Step 7 允許VNC服務通過防火牆

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

現在我可以通過使用運行在Win10 上的VNC viewer用戶端來遠程查看Centos 7的圖形介面

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/73/40/wKioL1X42YizNjAnAADImh1gEiQ473.jpg" title="1.PNG" alt="wKioL1X42YizNjAnAADImh1gEiQ473.jpg" />

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/73/44/wKiom1X419bTRQceAAdW9NG-iVo438.jpg" title="2.PNG" alt="wKiom1X419bTRQceAAdW9NG-iVo438.jpg" />可以看到Centos 7的案頭環境了

若需停止VNC服務,輸入如下指令。

[[email protected] ~]# systemctl stop [email protected]:1.service

禁用VNC服務從系統啟動(永久)

[[email protected] ~]# systemctl disable [email protected]:1.service

停止防火牆服務

[[email protected] ~]# systemctl stop firewall.service

Have a nice day!

在Centos 7上安裝VNC server

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.