环境为ubuntu20.04,阿里云轻量应用服务器
在试过csdn多数办法中,都是从更改vnc的xstartup文件参数出发来解决问题,我个人亲测不成功。
问题原因
在按照阿里云官方文档教程的步骤重新安装时,发现执行命令:
apt-get install vnc4server
报出以下错误(之前没注意):
Package vnc4server is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'vnc4server' has no installation candidate
说明之前灰屏的原因极有可能出在这里,阅读代码发现apt没有找到 vnc4server 的包,于是便打开网站Ubuntu Pakages Search搜索 vnc4server,得到结果如下:
即vnc4server属于universe仓库,并在版本bionic中,安装不成功的根本原因在与apt默认源中没有这个源。
解决方法
故我们打开并编辑apt的sources.list文件:
vi /etc/apt/sources.list
添加以下源:
deb http://archive.ubuntu.com/ubuntu/ bionic universe
保存退出,再执行命令:
sudo apt update
安装vnc:
apt-get install vnc4server
可以成功安装。
附阿里云安装VNC教程:
通过VNC搭建Ubuntu 18.04和20.04图形界面