一、安装webRTC环境的准备工作
1.centos 下载位置:
https://mirrors.openanolis.cn/anolis/8.4/isos/GA/x86_64/
2.win 10 没有 hyper
解决办法:【转】windows 没有hyper-v 解决方法
3.安装 centos
教程:https://www.jianshu.com/p/f4e5430266e1
4.centos 启动失败
解决办法:
5.centos 无法连接网络(ping 114.114.114.114 失败)
解决方法:
ip addr 查看网卡名称;
vi /etc/sysconfig/network-scripts/ifcfg-网卡名字:vi /etc/sysconfig/network-scripts/ifcfg-eth0
在文件中修改:ONBOOT=ON 修改为ONBOOT=yes
在该文件中添加 DNS1 = 8.8.8.8 DNS2=4.2.2.2
重启网卡 ifup eth0
二、centos 工具安装
yum -y install wget
yum -y install git
yum -y install python3-pip
yum -y install meson
install re2c
yum -y install cmake
yum -y install libevent-devel
yum -y install curl-devel
sudo yum install gcc-c++
git 全局配置:
git config --global http.sslVerify "false"
三、janus webRTC 环境安装
1.安装依赖
yum install libmicrohttpd-devel jansson-devel \
openssl-devel libsrtp-devel sofia-sip-devel glib2-devel \
opus-devel libogg-devel libcurl-devel pkgconfig \
libconfig-devel libtool autoconf automake
2.libnice
git clone https://gitlab.freedesktop.org/libnice/libnice
cd libnice
meson --prefix=/usr build && ninja -C build && sudo ninja -C build install
3.usrsctp
git clone https://github.com/sctplab/usrsctp
cd usrsctp
./bootstrap
./configure --prefix=/usr --disable-programs --disable-inet --disable-inet6 --disable-dependency-track
make && sudo make install
4.libsrtp
wget https://github.com/cisco/libsrtp/archive/v2.2.0.tar.gz
tar xfv v2.2.0.tar.gz
cd libsrtp-2.2.0
./configure --prefix=/usr --enable-openssl
make shared_library && sudo make install
5.websocket可不装
git clone https://libwebsockets.org/repo/libwebsockets
cd libwebsockets
mkdir build
cd build
cmake -DLWS_MAX_SMP=1 -DLWS_WITHOUT_EXTENSIONS=0 -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_C_FLAGS="-fpic" ..
make && sudo make install
如果git clone https://libwebsockets.org/repo/libwebsockets 下载不下来,可以换成如下地址
git clone https://github.com/warmcat/libwebsockets.git
6.janus-gateway
git clone https://github.com/meetecho/janus-gateway.git
cd janus-gateway
sh autogen.sh
./configure --prefix=/opt/janus
make && sudo make install
make configs
7.nodejs 安装
安装:yum install nodejs -y
查看版本:
- node -v
- npm -v
设置淘宝镜像:
- npm config set registry https://registry.npm.taobao.org
- npm install -g cnpm --registry=https://registry.npm.taobao.org
安装升级node版本工具:npm install -g n
升级node到稳定版:n stable
切换失效的解决办法:
- 查看 node 当前安装路径
which node #
/usr/local/bin/node #举个例子
- 编辑环境配置文件:
vim ~/.bash_profile
- 将下面两行代码插入到文件末尾:
export N_PREFIX=/usr/local #node实际安装位置,这里是/usr/local/bin/node
export PATH=$N_PREFIX/bin:$PATH
- 执行 source 使修改生效:
source ~/.bash_profile
安装http-server:
sudo npm -g install http-server
8.关闭防火墙:
//临时关闭
systemctl stop firewalld
//禁止开机启动
systemctl disable firewalld
9.启动:
后台启动janus:
cd /root/janus-gateway
/opt/janus/bin/janus >janus.log 2>&1 &
发布demo:
http-server --ssl --cert /home/ssl/cert.pem --key /home/ssl/key.pem
访问 https://192.168.254.131:8080即可访问了;
四、可能遇到的问题:
问题:/usr/bin/env: ‘python’: No such file or directory
解决方法:sudo ln -s /usr/bin/python3 /usr/bin/python
问题:hv_balloon: Balloon request will be partially fulfilled. Balloon floor reached
附:
Linux常用指令相关
Linux防火墙配置相关
我从来不相信什么懒洋洋的自由。我向往的自由是通过勤奋和努力实现的更广阔的人生。 我要做一个自由又自律的人,靠势必实现的决心认真地活着。