janus(webrtc server) 在阿里云centos7.4上的使用

参考

https://blog.****.net/u012231640/article/details/83618274#Webrtc_Server_289

机器

[[email protected] ~]# cat /etc/redhat-release

CentOS Linux release 7.4.1708 (Core)

执行脚本

#!/bin/sh
yum install -y epel-release && \
yum update -y && \
yum install -y deltarpm && \
yum install -y openssh-server sudo which file curl zip unzip wget && \
yum install -y libmicrohttpd-devel jansson-devel libnice-devel glib22-devel opus-devel libogg-devel pkgconfig  gengetopt libtool autoconf automake make gcc gcc-c++ git cmake libconfig-devel openssl-devel

#upgrade libsrtp 1.5.4
#wget https://github.com/cisco/libsrtp/archive/v1.5.4.tar.gz
#tar xfv v1.5.4.tar.gz
#cd libsrtp-1.5.4
#./configure --prefix=/usr --enable-openssl
#make shared_library && sudo make install

#cd -

wget https://github.com/cisco/libsrtp/archive/v2.0.0.tar.gz
tar xfv v2.0.0.tar.gz
cd libsrtp-2.0.0
./configure --prefix=/usr --enable-openssl
make shared_library && sudo make install

cd -

#install sofia-sip for sip-gateway plugin
wget https://sourceforge.net/projects/sofia-sip/files/sofia-sip/1.12.11/sofia-sip-1.12.11.tar.gz
tar zxf sofia-sip-1.12.11.tar.gz && cd sofia-sip-1.12.11 && ./configure --prefix=/usr CFLAGS=-fno-aggressive-loop-optimizations && make && make install

cd -

#install usrsctp for Data channel support
git clone https://github.com/sctplab/usrsctp && cd usrsctp && \
./bootstrap && \
./configure --prefix=/usr && make && make install

cd -

#install libwebsocket for android or ios instead of http/https
git clone https://github.com/warmcat/libwebsockets && \
mkdir libwebsockets/build && cd libwebsockets/build && \
cmake -DMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_C_FLAGS="-fpic" .. && \
make && make install

cd -

#Janus
#if cannot configure plugin sofia,Perhaps you should add the directory containing `sofia-sip-ua.pc' to the PKG_CONFIG_PATH environment variable,
#for example centos7 :export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/lib/pkgconfig
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/lib/pkgconfig
#if cannot load libsofia-sip-ua.so.0 , try ldconfig -v
git clone https://github.com/meetecho/janus-gateway.git && \
cd janus-gateway &&\
sh autogen.sh && \
./configure --prefix=/opt/janus --disable-rabbitmq --disable-docs &&\
make && make install && make configs

不过,有的下载的比较慢,可以先下载,然后替换下载地址。

nginx安装

yum install nginx

修改配置

1、/opt/janus/etc/janus/janus.transport.http.jcfg 里面的https改成true

2、nginx的证书使用janus安装目录下的

vim /etc/nginx/conf.d/default.conf

janus(webrtc server) 在阿里云centos7.4上的使用

#ssl_certificate /etc/nginx/ssl/nginx.crt;

   ssl_certificate /opt/janus/share/janus/certs/mycert.pem;

   #ssl_certificate_key /etc/nginx/ssl/nginx.key;

   ssl_certificate_key /opt/janus/share/janus/certs/mycert.key;

修改配置后,重启nginx

nginx -s -reload

启动

systemctl start nginx

cd /opt/janus/bin

./janus --debug-level=7 --nat-1-1=xxx.xxx.xxx.xxx --stun-server=xxx.xxx.xxx.xxx:xxxx

参数说明:

--nat-1-1:是ECS的外网ip

测试

janus(webrtc server) 在阿里云centos7.4上的使用