当前位置:网站首页>实战noVNC全过程操作(包含遇到的问题和解决)
实战noVNC全过程操作(包含遇到的问题和解决)
2022-08-11 05:12:00 【热心码民阿振】
项目场景:
为了公司项目服务系统的售后服务轻松、远程操控方便,使用VNC是一个很好的选择
工具准备:
资源准备:官网下载noVNC:Releases · novnc/noVNC · GitHub
开发工具和环境:Xshell7、Xftp7、和要部署的服务器(系统centos7)

实战操作:
步骤一:vnc服务安装
# which vncserver
# yum install tigervnc-server -y

步骤二:vnc服务配置(复制一份并且配置service文件为root用户,配置密码用于后面noVNC客户端登录时输入):
# cp /lib/systemd/system/[email protected] /etc/systemd/system/[email protected]:1.service
# vim /etc/systemd/system/[email protected]:1.service# vncpasswd


步骤三:关闭防火墙和设为开机启动(亲测没有用哈,要自己编写脚本,在步骤八有)、启动服务、查看端口号
# setenforce 0
# systemctl stop firewalld
# systemctl disable firewalld# systemctl enable [email protected]:1
# vncserver :1 #启动服务
# netstat -lntup|grep 59 #查看端口
tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN 2765/Xvnc
tcp6 0 0 :::5901 :::* LISTEN 2765/Xvnc
步骤四:安装解压noVNC
我下载的zip,所以unzip指令解压,如果时tar.gz则用tar命令:tar -xzvf file.tar.gz
# unzip noVNC-1.3.0.zip -d /usr/local #指定文件解压位置
步骤五:配置noVNC
生成self.pem文件放到noVNC/utils底下(原因:VNC的默认会话不是安全的,我们需要创建一个安全的VNC连接,一路回车就好)
# cd /usr/local/novnc-noVNC-cdfb336/utils
# openssl req -new -x509 -days 365 -nodes -out self.pem -keyout self.pem
步骤六:启动noVNC服务
# ../utils/novnc_proxy --vnc localhost:5901
报错:这个时候启动可能会报错:/usr/local/novnc-noVNC-cdfb336/utils/websockify/run: 第 4 行:exec: python3: 未找到(原因很清楚了:缺少python3)
解决:安装python3
1、python默认路径是 /usr/bin/,如有改动可以输入指令查看:# whereis python,这里可以看出我的服务最高指向python2.7
# cd /usr/bin/
# ll python*lrwxrwxrwx. 1 root root 7 6月 10 2020 python -> python2
lrwxrwxrwx. 1 root root 9 6月 10 2020 python2 -> python2.7
-rwxr-xr-x. 1 root root 7216 8月 7 2019 python2.7
2、安装(因为我的centos7默认没有相关依赖和工具包,下载相关依赖和工具包:epel、pip、wget)最后通过wget从官网下载压缩包,xz编译,tar解压,进入python3.6.8,将其放到/usr/local目录下,然后make手动编译,接着安装依赖zlib、zlib-deve,最后下载默认没有python3-pip 命令并查看一下版本
# yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
# yum -y install epel-release# yum install python-pip
# pip install wget
# wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tar.xz
# xz -d Python-3.6.8.tar.xz
# tar -xf Python-3.6.8.tar
# cd Python-3.6.8
# ./configure prefix=/usr/local/python3
# make && make install
# yum install zlib zlib
# yum install zlib zlib-devel
# yum install -y python3-pip
# python3 -V
步骤七:主机的浏览器访问服务器(http://服务器ip:6080/vnc.html)
# /usr/local/novnc-noVNC-cdfb336/utils/novnc_proxy --vnc localhost:5901



步骤八:VNC和noVNC设置开机自启
1、编辑vncserver脚本
# vim /etc/init.d/vncserver
# chmod 755 /etc/init.d/vncserver
export USER='root'
eval cd ~$USER
case "$1" in
start)
# 启动命令行。此处自定义分辨率、控制台号码或其它参数。
su $USER -c '/usr/bin/vncserver -depth 16 -geometry 1024x768 :1'
echo "Starting TightVNC server for $USER "
;;
stop)
# 终止命令行。此处控制台号码与启动一致。
su $USER -c '/usr/bin/vncserver -kill :1'
echo "vncserver stopped"
;;
*)
echo "Usage: /etc/init.d/vncserver {start|stop}"
exit 1
;;
esac
exit 0
2、编辑novnc脚本
# vim /usr/local/start_novnc.sh
# chmod 755 /usr/local/start_novnc.sh
#启动novnc服务
/usr/local/novnc-noVNC-cdfb336/utils/novnc_proxy --vnc localhost:5901
3、脚本置于自启动文件末尾(/etc/rc.d/rc.local)
vim /etc/rc.d/rc.local
#update.rc.d自启动
/etc/init.d/vncserver start
#novnc开机自启动
/usr/local/start_novnc.sh
结束:最后开机重启即可
希望对大家有所帮助,有所启发!!!!!!!
边栏推荐
猜你喜欢

prometheus:(二)监控概述(你永远逃不出我的手掌哈哈)

Thymeleaf

Switch and Router Technology-27-OSPF Route Redistribution

Optimization is a kind of habit low starting point is the "standing near the critical"

The use of async (asynchronous) and await

ARM结构体系4:嵌入式硬件平台接口开发

网络技能树

Redis-数据类型(基本指令、String、List、Set、Hash、ZSet、BitMaps、HyperLogLog、GeoSpatial)/发布和订阅

How IP-Guard prohibits running U disk programs

C Language: Practical Debugging Tips
随机推荐
BGP Comprehensive Experiment
Kong实现禁止国外IP访问
svg-icon的使用方法(svg-sprite-loader插件)
2.2 user manual] [QNX Hypervisor 10.15 vdev timer8254
Paper Notes: Bag of Tricks for Long-Tailed Visual Recognition with Deep Convolutional Neural Networks
交换机和路由器技术-25-OSPF多区域配置
IDEA中配置checkstyle
提升你工作效率的技巧,你得知道——Navitcat 快捷键
Weekly recommended short video: your commonly used Polaroid, its predecessor turned out to be like this!
async(异步)和await的使用
Internet Protocol 1
[QNX Hypervisor 2.2 User Manual] 10.16 vdev virtio-blk
Redis详解
Switch and Router Technology-31-Extended ACL
【无标题】2022年胺基化工艺考试题模拟考试题库及在线模拟考试
Day38 LeetCode
【嵌入式开源库】MultiButton的使用,简单易用的事件驱动型按键驱动模块
FPGA engineer interview questions collection 111~120
ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/data/xxxx
Mysql introductory exercise