环境:


  1. [email protected]:~# cat /etc/issue 
  2. Ubuntu 12.04 LTS \n \l 

 

 需求:现在需要远程连接Ubuntu的图形界面,因为有一个程序是需要使用图形界面配置的。

默认情况下,Ubuntu server是没有图形界面的,使用Xmanager远程连接Ubuntu,连接完成后,本来想使用Xmanager自带的功能,来实现弹出一个图形界面的,但是不管怎么弹,该程序就是弹不出来,很纠结,用Xclock测试,是可以的。只能另行它法。

以前配置VNC,都是在RedHat里面配置的,Ubuntu里面没弄过,这就研究了一下。下面详细的说一下配置过程,使用的图形程序为Xface

一、安装配置VNC

1、首先安装VNC

 


  1. # apt-get install vnc4server 

2、为VNC设置密码

 


  1. [email protected]:~/.vnc# vncpasswd  
  2. Password: 

输入密码,然后再确认一遍,就OK了。

3、启动VNC

 


  1. [email protected]:~# vncserver :1 
  2.  
  3. New 'node1:1 (root)' desktop is node1:1 
  4.  
  5. Starting applications specified in /root/.vnc/xstartup 
  6. Log file is /root/.vnc/node1:1.log 
  7.  
  8. [email protected]:~# ps -ef | grep vnc 
  9. root      1768     1  0 06:10 pts/0    00:00:00 Xvnc4 :1 -desktop node1:1 (root) -auth /root/.Xauthority -geometry 1024x768 -depth 16 -rfbwait 30000 -rfbaut 
  10. h /root/.vnc/passwd -rfbport 5901 -pn -fp /usr/X11R6/lib/X11/fonts/Type1/,/usr/X11R6/lib/X11/fonts/Speedo/,/usr/X11R6/lib/X11/fonts/misc/,/usr/X11R6/lib/X11/fonts/75dpi/,/usr/X11R6/lib/X11/fonts/100dpi/,/usr/share/fonts/X11/misc/,/usr/share/fonts/X11/Type1/,/usr/share/fonts/X11/75dpi/,/usr/share/fonts/X11/100dpi/ -co /etc/X11/rgb 

启动成功

二、客户端连接

客户端安装vncview,然后连接

 

Ubuntu server配置远程VNC服务

输入IP的时候,输入 IP:NO,即ip地址加会话号,刚才开户的是1,这里就输入 

1.1.1.1:1

然后输入完密码,就可以连接了

 

Ubuntu server配置远程VNC服务

因为没有桌面环境,所以,我们需要安装一个,这里使用Xface

三、安装Xface

 


  1. # apt-get install xfce4 

过程比较漫长,大小有200MB左右。等安装完成后,我们就可以使用VNC调用Xface了

更改VNC配置,加载Xface桌面

 


  1. [email protected]:~# pwd 
  2. /root 
  3. [email protected]:~# cd .vnc/ 
  4. [email protected]:~/.vnc# ls 
  5. node1:1.log  node1:1.pid  passwd  xstartup 
  6. [email protected]:~/.vnc# vim xstartup  

把原来的配置给注释掉,新增Xface的配置即可,配置文件下

 


  1. [email protected]:~/.vnc# cat xstartup  
  2. #!/bin/sh 
  3.  
  4. # Uncomment the following two lines for normal desktop: 
  5. # unset SESSION_MANAGER 
  6. # exec /etc/X11/xinit/xinitrc 
  7.  
  8. [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup 
  9. [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources 
  10. xsetroot -solid grey 
  11. vncconfig -iconic & 
  12. #x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & 
  13. #x-window-manager & 
  14.  
  15. sesion-manager & xfdesktop & xfce4-panel & 
  16. xfce4-menu-plugin & 
  17. xfsettingsd & 
  18. xfconfd & 
  19. xfwm4 & 

然后重新启动VNC

 


  1. [email protected]:~/.vnc# vncserver -kill :1 
  2. Killing Xvnc4 process ID 1844 
  3. [email protected]:~/.vnc# vncserver :1 
  4.  
  5. New 'node1:1 (root)' desktop is node1:1 
  6.  
  7. Starting applications specified in /root/.vnc/xstartup 
  8. Log file is /root/.vnc/node1:1.log 

再用客户端连接

 

Ubuntu server配置远程VNC服务

 

看到了Xface了,说明OK了,至此,已经配置完毕。