How to setup VNC server on NanoPC-T4

From FriendlyELEC WiKi
Revision as of 08:55, 16 May 2019 by Tzs (Talk | contribs) (updated by API)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

查看中文

1 Step1: 安装VNC Server

sudo apt-get install tightvncserver

2 Step2: 设置密码

运行vnc server一次,会生成配置文件,并提示你为VNC Server设置一个密码:

tightvncserver :1

设置密码后,为了方便接下来的操作,先退出Vnc server:

tightvncserver -kill :1

3 Step3: 配置VNC server

编辑~/.vnc/xstartup文件,在尾部添加:

lxterminal &
/usr/bin/lxsession -s LXDE &

手动启动VNC Server,测试一下是否可以工作:

vncserver -geometry 1280x800

在电脑上打开VNC客户端,输入开发板IP地址与5901的端口号,比如开发板的IP是192.168.1.131,则输入 192.168.1.131:5901,如下图所示:
Vncserver-inputaddress.png
连接成功的话,进入下一步。

4 Step4: 设置开机自动启动VNC server

新建一个文件 /etc/systemd/system/vncserver@.service,内容如下:

[Unit]
Description=Start TightVNC server at startup
After=syslog.target network.target
 
[Service]
Type=forking
User=pi
PAMName=pi
PIDFile=/home/pi/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i
ExecStop=/usr/bin/vncserver -kill :%i
 
[Install]
WantedBy=multi-user.target

创建符号链接以实现开机自启动:

sudo ln -s /etc/systemd/system/vncserver@.service /etc/systemd/system/multi-user.target.wants/vncserver@1.service

重启开发板:

sudo reboot

5 Step5: 连接到VNC server

在电脑上打开VNC Viewer,输入开发板IP地址与5901的端口号登录开发板,显示桌面如下图所示:
Vncserver-friendlydesktop.png