關於VNC的開機啟動

來源:互聯網
上載者:User

同時需要在兩台linux伺服器上安裝VNCserver(一台Centos、一台Asianux),卻遇到了同樣的問題,開機VNC不能自己啟動,需要輸入vncserver才能串連上,下面是解決過程: 一、安裝配置VNC 我的兩台機器都預設安裝過了VNC,沒有裝的上google.
vncserver
passwd: ##第一次運行vncserver,要求你輸入串連的密碼。
verify:
New 'localhost:1 (root)' desktop is localhost:1
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost:1.log
加入服務,讓其開機啟動
#chkconfig vncserver on
# chkconfig --list vncserver
vncserver 0:off 1:off 2:on 3:on 4:on 5:on 6:off ##查看是否成功,2-5為on就行
配置遠端桌面環境
#vi .vnc/xstartup
unset SESSION_MANAGER  ##把這兩句前面的#去掉
exec /etc/X11/xinit/xinitrc
gnome-session &  ##Centos用的是這個
startkde &       ##Redflag用的是這個,不知道為什麼看到它的案頭,可想跺顯示器
twm &            ##類似SSH的介面
建立防火牆策略:
#iptables -A INPUT -p tcp --dport 5901 -j ACCEPT ##VNC預設連接埠5901
#iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination        
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:5901
Chain FORWARD (policy ACCEPT)
target     prot opt source               destination        
Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
儲存防火牆策略: 許多人都忘記這一步,結果一重啟還是串連不上。
#iptables-save > /etc/sysconfig/iptables  ##產生儲存規則的檔案,我也用了service iptables save這個命今也能建置規則檔案,但開機卻載入不了。
下面肉戲來了,也走了很多彎路: 紅色為錯誤過程,請誤照搬 在這一步的時候我用vncserver命令啟動,兩台機器都成功看到案頭,很是激動,結果一重啟還是串連不上,必須再輸入vncserver才能串連上。一開始在網上找資料說VNC是使用者層面的,就想當然的以為讓它開機自動執行vncserver命令:
#vi /etc/rc.d/rc.local
/usr/bin/vncserver  #Centos如果用這句所有控制台會啟動卡在快要輸使用者的地方,唉,進救援吧
                    ##Redflag到可以啟動,但串連不上
#chkconfig vncserver off   #也試過把加入服務取消,還是不行,結果如上
還是把這句去掉吧,經實驗只是要改/etc/sysconfig/vncserver檔案:
#vi /etc/sysconfig/vncserver
VNCSERVERS="2:root"  ##一定要改成2或者3,不然還是串連不上,真二呀
VNCSERVERARGS[2]="-geometry 800*600"  ##TNND,那個叉是怎麼輸上去的?
OK!重啟驗證一下吧,PS:/etc/rc.d/init.d/vncserver restart 不會關閉VNC串連,要用vncserver -kill :2
本文出自 “kras-linux” 部落格

聯繫我們

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