背景介绍:写Ruby时候有些前端信息需要测试,可以使用Spinach测试,但是运行起来后看不见前端页面的实际变化情况。所以安装配置VNC来实现可视化。
首先查看一下自己的系统:(看到我是Ubuntu 18.04)
# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.3 LTS
Release: 18.04
Codename: bionic
然后你要切到你自己的工作目录下,需要非root 用户
接下来开始安装配置VNC。
1.先更新一下软件包:
lemon2@haiyu-personal:~$ sudo apt update
2.安装 VNC 服务器:
~$ sudo apt -y install vnc4server
升级到Ubuntu 22.04后,发现这条命令有错误
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
咱们换成这条
sudo apt install tightvncserver
3.安装 Xfce 桌面环境:
~$ sudo apt install xfce4 xfce4-goodies
到这就安装好了,接下来配置VNC
4.直接请使用 vncserver 命令设置安全密码并创建初始配置文件:
~$ vncserver
5.系统会提示输入密码。
6.停止服务配环境:
~$ vncserver -kill :1
7.备份一下原始文件:
mv ~/.vnc/xstartup ~/.vnc/xstartup.bak
将下面内容放进去:
vim ~/.vnc/xstartup
#!/bin/bash
xrdb $HOME/.Xresources
startxfce4 &
文件中的第一条命令xrdb $HOME/.Xresources
告诉 VNC 的图形用户界面框架读取服务器用户的.Xresources
文件。用户可以在.Xresources
文件中更改图形桌面的某些设置,如终端颜色、光标主题和字体渲染。第二条命令是让服务器启动 Xfce。无论何时启动或重启 VNC 服务器,这些命令都会自动执行。
8.添加一下权限:
sudo chmod +x ~/.vnc/xstartup
9.就可以正常启动服务器了:
~$ vncserver
New 'haiyu-personal:2 (lemon2)' desktop is haiyu-personal:2
Starting applications specified in /home/lemon2/.vnc/xstartup
Log file is /home/lemon2/.vnc/haiyu-personal:2.log
服务器端装好了,电脑怎么访问呢?简单,下载一个VNC Viewer,把你的server地址啥的配好就可以了。
Ubuntu22.04情况不太一样,具体看这里在Ubuntu 22.04上安装配置VNC实现可视化-优快云博客
空白的地方右击就可以看到命令行,在里面运行你的spinach 命令吧。
如果你收到这样的提示
不要慌,在File->Preferences->Proxy选择 Do not use a proxy.
全文完,感谢阅读。
https://computingforgeeks.com/how-to-install-vnc-server-on-ubuntu/https://computingforgeeks.com/how-to-install-vnc-server-on-ubuntu/
https://linuxize.com/post/how-to-install-and-configure-vnc-on-ubuntu-18-04/https://linuxize.com/post/how-to-install-and-configure-vnc-on-ubuntu-18-04/