1. 先檢查下是否有安裝VNC
[root@yanghg yanghg]# rpm -qa | grep tigervnc
tigervnc-1.1.0-18.el6.x86_64
tigervnc-server-1.1.0-18.el6.x86_64
如果沒有安裝則執行:
[root@yanghg yanghg]# yum install tigervnc-server -y
已加載插件:fastestmirror, refresh-packagekit, security
設置安裝進程
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository contrib is listed more than once in the configuration
Loading mirror speeds from cached hostfile
* base: mirrors.btte.net
* epel: mirror.premi.st
* extras: mirrors.btte.net
* linuxtech-release: pkgrepo.linuxtech.net
* nux-dextop: mirror.li.nux.ro
* rpmfusion-free-updates: mirror.bjtu.edu.cn
* rpmfusion-nonfree-updates: mirror.bjtu.edu.cn
* updates: mirrors.aliyun.com
包 tigervnc-server-1.1.0-18.el6.x86_64 已安裝並且是最新版本
無須任何處理
[root@yanghg yanghg]#
2. 執行[root@yanghg yanghg]# vncserver
第一次執行會讓你輸入密碼,至少6位,后續在vncviewer連接服務器端主機中需要用到。
注意:后續可用vncpasswd命令修改密碼
3. 啟動vncserver服務
啟動vncserver服務有兩種方式。
第一種:/etc/init.d/vncserver start,此種方式需要編輯配置文件。
[root@node1 ~]# /etc/init.d/vncserver start
Starting VNC server: no displays configured [FAILED]
報以上錯誤,需修改配置文件
$ vim /etc/sysconfig/vncservers
4. /etc/sysconfig/vncservers 文件添加以下內容:
VNCSERVERS="1:root 2:yanghg"
VNCSERVERARGS[1]="-geometry 1920x1080 -depth 32 -nolisten tcp"
VNCSERVERARGS[2]="-geometry 1920x1080 -depth 32 -nolisten tcp"
5. # vim /root/.vnc/xstartup
#twm & //注釋該行
末尾追加如下行:
gnome-session & //如果為KDE桌面,則修改為:startkde &
其他用戶同理修改
6. 最后啟動vncserver 並設置為開機啟動,執行以下
# service vncserver start
# chkconfig vncserver on
補充:
如果執行# service vncserver start有發現報以下錯誤
2:yanghg
You will require a password to access your desktops.
getpassword error: Inappropriate ioctl for device
Password:3:yuy
You will require a password to access your desktops.
getpassword error: Inappropriate ioctl for device
Password: [FAILED]
讓用戶設置密碼(必須切換到配置文件中添加的用戶名下,如yanghg)
# vncpasswd
7. 看看新生成的桌面對應的窗口
[root@yanghg yanghg]# netstat -ntlup |grep vnc
tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN 2911/Xvnc
tcp 0 0 0.0.0.0:5902 0.0.0.0:* LISTEN 3050/Xvnc
參考鏈接:http://www.cnblogs.com/ivictor/archive/2015/08/27/4760914.html