The process of building a VNC server

1. Origin

In the near future, we need a development platform with better performance, but the performance of the local computer is not very good, so we have the idea of ​​using Aliyun's cloud server. We can try to install the Linux desktop environment in the cloud, and then use VNC to perform remote desktop. connect.

2. Install the Ubuntu desktop environment on Alibaba Cloud

2.1 Install related software

After we have purchased the ECS server on Alibaba Cloud, we can use xshell to remotely log in to the server. The Linux distribution we use this time is Ubuntu server 16.04. After the system is started, we first update the server:

sudo apt-get update
sudo apt-get upgrade

Next install the desktop environment:

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

We can also enter directly sudo apt-get install ubuntu-desktop, but this will install libreOffice and other software unrelated to development.

There are a lot of programs to install, we Ycan start downloading and installing after entering:

Enter image description

Install vnc4server:

sudo apt-get install vnc4server

2.2 Configure vncserver

To run vncserver, enter the following command:

vncserver :1

Enter image description

vncserver will prompt you to set a password, you can enter the same password twice according to the situation. In this way, the vncserver is started, but we cannot access the vnc server through the vnc client normally.

Enter image description

Because in Alibaba Cloud's security policy, we did not release the port of vncserver , check the port that vncserver listens to.

Enter image description

At the same time, we need to release port 5901 in the Alibaba Cloud console.

Enter image description

Next we connect to the vnc server again

Enter image description

The system prompts that our communication is not encrypted. We have not completed the setup of vncserver, and now connect with the vnc client, the system returns only a white screen , because the gnome environment has not been started:

Enter image description

Next, we will add a statement to start gnome in the vncserver startup file. Before modifying the vncserver startup file, we need to close the vncserver. The command is as follows:

vncserver -kill :1

Then, we add the following statement to ~/.vnc/xstartup:

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

The final edit result is:

Enter image description

Start vncserver again

vncserver :1

According to the vncserver man manual, the command after the command :1means "display number":

Enter image description

After the vnc service starts, the output:

Enter image description

We can now successfully use the vnc client to connect to the remote vnc server:

Enter image description

Next, we can also modify the resolution of the vnc server. According to the man manual of vncserver, we can geometryset the resolution through options:

Enter image description

vncserver -kill :1
vncserver :1 -geometry 1920x1080

At this point, we can see a vnc desktop with a resolution of 1920x1080.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324996648&siteId=291194637