先更新一下软件源
apt-get update
apt-get upgrade
sudo apt-get install xorg lxde-core
中途提示选择哪个为默认 选第一个
sudo apt-get install tightvncserver
设置密码
vncpasswd
记得按N
生成配置文件
vncserver
编辑生成的配置文件
nano /root/.vnc/xstartup
末尾添加
lxterminal &
/usr/bin/lxsession -s LXDE &
control X control Y 保存退出
测试是否成功
vncserver
------------------------------------------
root@ubuntu:/home/xtimefun01# vncserver
New 'X' desktop is ubuntu:2 (端口号)
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/ubuntu:2.log
vncviewer 软件里
ip 和 端口号
连接 ok
设置开机自启动
nano /etc/init.d/tightvncserver
#!/bin/sh
### BEGIN INIT INFO
# Provides: tightvncserver
# Required-Start: $local_fs
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/stop tightvncserver
### END INIT INFO
# More details see:
# http://www.penguintutor.com/linux/tightvnc
### Customize this entry
# Set the USER variable to the name of the user to start tightvncserver under
export USER='pi' //修改成自己的userid
### End customization required
eval cd ~$USER
case "$1" in
start)
# 启动命令行。此处自定义分辨率、控制台号码或其它参数。
su $USER -c '/usr/bin/tightvncserver -depth 16 -geometry 1280x720 :1'
echo "Starting TightVNC server for $USER "
;;
stop)
# 终止命令行。此处控制台号码与启动一致。
su $USER -c '/usr/bin/tightvncserver -kill :1'
echo "Tightvncserver stopped"
;;
*)
echo "Usage: /etc/init.d/tightvncserver {start|stop}"
exit 1
;;
esac
exit 0
sudo chmod 755 /etc/init.d/tightvncserver
sudo update-rc.d tightvncserver defaults
reboot
链接:https://blog.csdn.net/chenguang_work/java/article/details/86241361