我使用的阿里云服务器为Ubuntu16.06,可通过安装VNC Server实现图形化的访问。
一、首先,需要在本地环境下安装VNC连接工具(我的本地环境是Win7),可以使用TightVNC Viewer,下载对应版本的即可
二、在云服务器上安装VNC Server:
- 连接上实例
- 运行
apt-get update
更新源 - 通过命令
apt-get install vnc4server -y
安装vnc4server - 安装成功了以后,通过命令
vnc4server
开启VNC服务并设置连接的密码 - 启动成功了以后,会在当前用户的主目录下生成一个`程序会自动在当前用户(本示例中为root)主目录下产生一个.vnc目录
- 运行命令
ps -ef | grep vnc
可查看是否服务已经启动,并且此时可以看到其服务的端口号(我的是5901)
- 运行命令`apt-get install xfce4安装xfce4
- 运行命令vim /root/.vnc/xstartup修改vnc4server启动文件为:
#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
#xrdb $HOME/.Xresources
#xsettroot -solid grey
#startxfce4&
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
sesion-manager & xfdesktop & xfce4-panel &
xfce4-menu-plugin &
xfsettingsd &
xfconfd &
xfwm4 &
9.生成新的会话
vncserver -kill :1 #杀掉原来的桌面进程(假设桌面号为:1)
vncserver :1 # 生成新的会话
10.登录ESC管理控制台,进入左侧菜单栏的网络和安全->安全组中,如果没有安全组需要先创建,如果有的话,点击实例下的配置规则,添加安全组规则
11.在本地机的VNC Viewer上连接实例,就可以实现图像化的访问了