VNC 可以實現對另外的計算機的操作:
A : 可以訪問另一個計算機,采用命令終端 或者窗口界面。
B : 可以遠程控制另一個計算機,兩台同步顯示操作。
看看簡單,但是實際沒有readme所說的那么簡單。
本文介紹在CentOS7.1下安裝VNC,讓Win7遠程桌面Linux解決了不少問題,寫個教學貼,給新手們看看,如果你們碰到同樣的問題,就可以迅速解決,無需頭疼甚至放棄了。
1、檢查是否安裝VNC
rpm -q tigervnc tigervnc-server
2、安裝X-Window
yum check-update yum groupinstall "X Window System" yum install gnome-classic-session gnome-terminal nautilus-open-terminal control-center liberation-mono-fonts unlink /etc/systemd/system/default.target ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target reboot #重啟機器
3、安裝VNC
yum install tigervnc-server -y
4、從VNC備份庫中復制service文件到系統service服務管理目錄下【原文這里存在錯誤,不是創建vncserver@:1.service文件夾】
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service #復制並被重命名為vncserver@:1.service
5、修改vncserver@:1.service文件
#進入/etc/systemd/system目錄
cd /etc/systemd/system
#編輯配置文件
vim vncserver@: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
#如果不是root用戶 PIDFile=/home/anjos/.vnc/%H%i.pid
6、重新加載 systemd
#由於在systemd中添加了東東,得讓系統重新加載 systemctl daemon-reload
7、為vncserver@:1.service設置密碼
vncpasswd
8、關閉防火牆
CentoS7默認采用新防火牆firewall,不在用iptables
[使用firewall]
firewall-cmd --permanent --add-service vnc-server#添加訪問權限
systemctl restart firewalld.service#重啟firewalld
#systemctl stop firewalld.service #停止firewall(start,啟動)
#systemctl disable firewalld.service #設置開機禁止firewall(enable 開機啟動)
我的直接關閉防火牆,虛擬機測試防火牆關閉可以解決大部分軟件的安裝訪問問題,真實生產環境的配置下允許防火牆通過具體服務即可。
[使用iptables]
yum -y install iptables-services#安裝iptables
vi /etc/sysconfig/iptables#修改iptables防火規則,在合適的位置加上如下一句
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5900:5903 -j ACCEPT
systemctl restart iptables.service #重啟防火牆使配置生效-----systemctl status iptables.service#查看狀態
systemctl stop iptables.service #啟動iptables(start)
systemctl disable iptables.service #禁止防火牆開機啟動(enable)#設置防火牆開機啟動
[注意]安裝iptables后可以使用
service iptables status#查看防火牆狀態
service iptables stop#關閉防火牆
chkconfig iptables --list#查看防火牆開機啟動狀態
chkconfig iptables off#關閉防火牆開機啟動
9、啟動VNC服務(設置開機啟動)
systemctl enable vncserver@:1.service #設置開機啟動 systemctl start vncserver@:1.service #啟動vnc會話服務
#systemctl status vncserver@:1.service #查看nvc會話服務狀態
#systemctl stop vncserver@:1.service #關閉nvc會話服務
10、在win7上下載VNC Viewer
下載地址:http://www.realvnc.com/download/viewer/
下載后,直接雙擊exe即可
11、訪問
使用你的ip加上一個1即可
vnc登錄時connection refused(10061)解決方法
問題:當你在windows上連接Linux上vnc服務器時,點擊connect后彈出connect:connect refused(10061)警告框時連接被拒絕。
首先,如果你的VNC配置沒有問題並且在linux那邊通過service vncserver status查看顯示“Xvnc (pid 3644) 正在運行”,表明確實已經啟動。
那么原因就是你沒有在VNC客戶端輸入IP地址的時候加上桌面號。沒加的話就會出現上面的錯誤。正確的寫法為IP:1
這樣就會連接上並提示讓你輸入密碼了!
ok!搞定!
VNC桌面亂碼問題解決
1.檢查Centos7系統中系統語言是否為支持中文,命令:
vim /etc/locale.conf
LANG="zh_CN.UTF-8" #LANG="en_US.UTF-8" #默認語言為英文
LANGUAGE=
"zh_CN.UTF-8:zh_CN.GB2312:zh_CN"
SUPPORTED=
"zh_CN.UTF-8:zh_CN:en_US.UTF-8:en_US:en"
SYSFONT=
"lat0-sun16"