###服务器是否配置了VNCSERVER,可以在命令行下敲入以下命令查看:
[root@localhost: ~]#rpm -qa |grep vnc
###配置VNC
1. 机器IP为:10.0.0.100
2. 在windows上面安装VNC viewer。
3. 在Linux上开一个命令窗口,执行 命令
vncserver
并设置密码。
4. 在linux上面开一个命令行窗口,执行"vi /root/.vnc/xstartup", 把最后一行修改为 "gnome &",保存,退出。
5. 再执行一遍 "vncserver",重启vnc服务。
例如:
```
[gw@max .vnc]$ vncserver
You will require a password to access your desktops.
Password:
Verify:
New 'max:7 (gwei)' desktop is amax:7
Starting applications specified in /home/gw/.vnc/xstartup
Log file is /home/gw/.vnc/max:7.log
[gw@max .vnc]$
```
6. 在Windows上面用vnc viewer登录,server框里填写10.0.0.100:1
冒号前面是ip,后面表示第1个console.
密码是 前面第3步设置的vncserver的密码。
注意:第5步中的7.log等信息表明:应该server框里填写10.0.0.100:7进行登录
###VNCServer相关配置:
1. 启动 VNC Server:
打开终端执行:vncserver
第一次运行 vncserver,将会要求输入两次密码,
2. 停止 vncserver 的方法是:vncserver -kill :1
注意“:1”,表示停止第一个vnc桌面
3. 修改vnc密码的方法是执行 vncpasswd,输入两次密码即可。
4. 默认情况下VNC Viewer只能看到 VNC Server的命令行。
要VNC Viewer上可以看到Linux桌面需要做如下设置:
在VNC Viewer所在的机器上,取消/root/.vnc/xstartup文件中下面两行的注释即可:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
5. Linux启动后自动运行VNCServer
1) 在 系统设置>服务器设置>服务 中把 vncserver 打勾。
2) 打开配置文件/etc/sysconfig/vncservers,去掉下面这行的注释,
VNCSERVERS="1:root"
VNCSERVERARGS[1]="-geometry 800x600"
1表示VNC以桌面1运行,这样可以启动root的桌面。
6. VNC端口
如果需要从外网控制内网的某台Linux,则需要打开防火墙相应的端口,并在路由器上进行端口映射。
VNC给浏览器的端口是5800+N,给vncviewer的端口是5900+N,N是设置的display号
补充: 使用图形化界面连进去后就可以在System setting->Server setting->Services里面将
vncserver勾上,这样开机就会自动启动vncserver
或者, #chkconfig vncserver on