AWS Lightsail/EC2 Ubuntu 安裝桌面

低配的EC2服務器,運行桌面的話極其緩慢,打開什麼都會卡半分鐘,包括文件夾。看視頻就更別想了。而且一般也沒什麼需要桌面的需求,只是玩玩,知道能GUI桌面登錄就好了。

主要步驟如下:

  • 第一步:先在管理後臺開啓默認的5901端口。
  • 第二步:安裝VNC服務,如vnc4server
  • 第三步:安裝桌面(xfce4, ubuntu-desktop等)
  • 第四步:配置VNC文件~/.vnc/xstartup,設置開啓哪個桌面等參數
  • 第五步:重啓VNC服務

VNC服務:vnc4server

注意:vnc4server不支持MacOS自帶的vnc連接方法,需要安裝RealVNC的VNC Viewer一類軟件連接。

安裝:

$ sudo apt-get install vnc4server

開啓/關閉VNC服務的方法:

$ vncserver :1
$ vncserver -kill :1

另外,在使用前,必須要填寫VNC的配置文件~/.vnc/xstartup(比如選擇什麼桌面之類,根據桌面不同配置也不同),才能正確啓動。

輕量版桌面:xfce4

參考:How to install graphical Desktop in ec2 instance ubuntu16.04 (Linux) and access from mac

$ sudo apt-get install xfce4

需要配置的VNC文件是~/.vnc/xstartup文件,全部修改如下:

#!/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 &

配置好後,重啓VNC服務,即可登錄。

桌面很清簡:

image

默認Ubuntu桌面:ubuntu-desktop

參考:阿里雲ECS,Ubuntu Server 16.04安裝圖形界面遠程控制

$ sudo apt-get install ubuntu-desktop
$ sudo apt-get install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal

# 退出登錄
$ exec sh /etc/X11/xinit/xinitrc.

編輯VNC配置~/.vnc/xstartup(包括選擇默認桌面等):

#!/bin/sh

export XKL_XMODMAP_DISABLE=1
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &

gnome-panel &
gnome-settings-daemon &
metacity &
nautilus &
gnome-terminal &

配置好後,重啓VNC服務,即可登錄。

桌面非常醜,而且非常慢。

image

客戶端

Mac上文件夾裏自帶的VNC連接,不支持打開vnc4server生成的遠程桌面。所以必須要下載第三方客戶端。

推薦用免費簡單的VNCViewer
登錄的話直接在地址欄輸入類似:34.231.169.129:1即可,注意ip後面有個:1

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章