目录
一、安装依赖项
二、编译janus v1.1.0
三、生成ssl证书
四、编译配置nginx
五、编译turnserver
六、配置janus文件
七、编译janus报错记录
参考资料:
环境是ubuntu20.04
使用最新的janus v1.1.0代码。
一、安装依赖项
sudo apt-get install aptitude
sudo aptitude install libmicrohttpd-dev libjansson-dev libnice-dev libssl1.1 libsrtp2-dev libsofia-sip-ua-dev libglib2.0-dev libopus-dev libogg-dev libcurl4-openssl-dev pkg-config gengetopt libtool automake
sudo apt install cmake
sudo aptitude install libconfig-dev
sudo aptitude install libssl-dev
sudo aptitude install doxygen graphviz
# ffmpeg库 支持--enable-post-processing
sudo aptitude install libavcodec-dev libavformat-dev libswscale-dev libavutil-dev
git clone https://github.com/warmcat/libwebsockets.git
git branch -a
#当前最新版本v4.3
git checkout v4.3-stable
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_C_FLAGS="-fpic" ..
make && sudo make install
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
git clone https://github.com/Kurento/libusrsctp.git
cd libusrsctp
./bootstrap
./configure
make
sudo make install
wget https://ftp.gnu.org/gnu/libmicrohttpd/libmicrohttpd-0.9.71.tar.gz
tar zxf libmicrohttpd-0.9.71.tar.gz
cd libmicrohttpd-0.9.71/
./configure
make
sudo make install
二、编译janus v1.1.0
git clone https://github.com/meetecho/janus-gateway.git
git tag 查看当前的 tag,选择最新稳定的版本v1.1.0
git checkout v1.1.0
sh autogen.sh
./configure --prefix=/opt/janus --enable-websockets --enable-post-processing --enable-docs --enable-rest --enable-data-channels
make
sudo make install
三、生成ssl证书
mkdir -p ~/cert
cd ~/cert
# CA私钥
openssl genrsa -out key.pem 2048
# 自签名证书
openssl req -new -x509 -key key.pem -out cert.pem -days 366
四、编译配置nginx
wget http://nginx.org/download/nginx-1.20.1.tar.gz
tar xvzf nginx-1.20.1.tar.gz
cd nginx-1.20.1/
# 配置,一定要支持https
./configure --with-http_ssl_module
# 编译
make
#安装
sudo make install
配置
sudo vim /usr/local/nginx/conf/nginx.conf
把最后一段的注释打开,修改证书地址(ssl_certificate、ssl_certificate_key)和janus页面地址(root):
server {
listen 443 ssl;
server_name localhost;
ssl_certificate /home/jiang/cert/cert.pem;
ssl_certificate_key /home/jiang/cert/key.pem;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root /opt/janus/share/janus/demos;
index index.html index.htm;
}
}
启动nginx
sudo /usr/local/nginx/sbin/nginx
可以访问了:https://ip
五、编译turnserver
turnserver是一个穿透服务。
依赖库
sudo apt-get install libssl-dev
sudo apt-get install libevent-dev
编译
wget http://coturn.net/turnserver/v4.5.0.7/turnserver-4.5.0.7.tar.gz
tar xfz turnserver-4.5.0.7.tar.gz
cd turnserver-4.5.0.7
./configure
make
sudo make install
启动
sudo nohup turnserver -L 0.0.0.0 --min-port 30000 --max-port 60000 -a -u abc:123456 -v -f -r nort.gov &
查看是否启动正常
jiang@ubuntu:~/work/janus$ ps -ef | grep turnserver
root 37220 29777 0 16:41 pts/1 00:00:00 sudo nohup turnserver -L 0.0.0.0 --min-port 30000 --max-port 60000 -a -u abc:123456 -v -f -r nort.gov
root 37221 37220 0 16:41 pts/1 00:00:00 turnserver -L 0.0.0.0 --min-port 30000 --max-port 60000 -a -u abc:123456 -v -f -r nort.gov
jiang 37253 29777 0 16:41 pts/1 00:00:00 grep --color=auto turnserver
关闭,直接kill
sudo kill -9 pid
六、配置janus文件
cd /opt/janus/etc/janus/
首先将.sample后缀全部去掉
cd /opt/janus/etc
sudo cp -r janus janus_bak
cd janus
批量重命名,去掉.sample文件后缀
sudo rename 's/\.sample$//' *.sample
修改/opt/janus/share/janus/demos/settings.js
var server = null;
if(window.location.protocol === 'http:')
server = "http://" + window.location.hostname + ":8088/janus";
else
server = "https://" + window.location.hostname + ":8089/janus";
//强制使用websocket,否则有可能点击start以后无响应
server = "wss://" + window.location.hostname + ":8989";
配置/opt/janus/etc/janus/janus.jcfg
certificates: {
cert_pem = "/home/jiang/cert/cert.pem"
cert_key = "/home/jiang/cert/key.pem"
#cert_pwd = "secretpassphrase"
#dtls_accept_selfsigned = false
#dtls_ciphers = "your-desired-openssl-ciphers"
#rsa_private_key = false
}
nat: {
stun_server = "192.168.101.175"
stun_port = 3478
nice_debug = false
#full_trickle = true
#ice_nomination = "regular"
#ice_keepalive_conncheck = true
#ice_lite = true
#ice_tcp = true
turn_server = "192.168.101.175"
turn_port = 3478
turn_type = "udp"
#此处的user:pwd,对应着turnserver的abc:123456
turn_user = "abc"
turn_pwd = "123456"
......
配置/opt/janus/etc/janus/janus.transport.http.jcfg
general: {
json = "indented" # Whether the JSON messages should be indented (default),
# plain (no indentation) or compact (no indentation and no spaces)
base_path = "/janus" # Base path to bind to in the web server (plain HTTP only)
http = true # Whether to enable the plain HTTP interface
port = 8088 # Web server HTTP port
https = true # Whether to enable HTTPS (default=false)
secure_port = 8089 # Web server HTTPS port, if enabled
}
certificates: {
cert_pem = "/home/jiang/cert/cert.pem"
cert_key = "/home/jiang/cert/key.pem"
#cert_pwd = "secretpassphrase"
#ciphers = "PFS:-VERS-TLS1.0:-VERS-TLS1.1:-3DES-CBC:-ARCFOUR-128"
}
配置/opt/janus/etc/janus/janus.transport.websockets.jcfg
general: {
json = "indented" # Whether the JSON messages should be indented (default),
ws = true # Whether to enable the WebSockets API
ws_port = 8188 # WebSockets server port
wss = true # Whether to enable secure WebSockets
wss_port = 8989 # WebSockets server secure port, if enabled
}
certificates: {
cert_pem = "/home/jiang/cert/cert.pem"
cert_key = "/home/jiang/cert/key.pem"
}
启动janus
sudo /opt/janus/bin/janus --debug-level=7
七、编译janus报错记录
configure: error: Doxygen 1.8.13 not usable: versions between 1.8.12 and 1.8.14 are known to render poorly.
删除Doxygen
sudo apt autoremove doxygen
下载新版本
git clone https://github.com/doxygen/doxygen.git
cd doxygen/
git tag
git checkout Release_1_8_19
mkdir build
cd build
cmake -G "Unix Makefiles" ..
make
sudo make install
编译doxygen源码报错
Could NOT find FLEX (missing: FLEX_EXECUTABLE)
sudo apt-get install flex
sudo apt-get install bison
编译janus报错
/home/jf/workspace/janus/janus-gateway/src/dtls.c:877: undefined reference to `srtp_crypto_policy_set_aes_gcm_256_16_auth'
/home/jf/workspace/janus/janus-gateway/src/dtls.c:878: undefined reference to `srtp_crypto_policy_set_aes_gcm_256_16_auth'
/home/jf/workspace/janus/janus-gateway/src/dtls.c:912: undefined reference to `srtp_crypto_policy_set_aes_gcm_256_16_auth'
/home/jf/workspace/janus/janus-gateway/src/dtls.c:913: undefined reference to `srtp_crypto_policy_set_aes_gcm_256_16_auth'
/home/jf/workspace/janus/janus-gateway/src/dtls.c:916: undefined reference to `srtp_crypto_policy_set_aes_gcm_128_16_auth'
/home/jf/workspace/janus/janus-gateway/src/dtls.c:917: undefined reference to `srtp_crypto_policy_set_aes_gcm_128_16_auth'
/home/jf/workspace/janus/janus-gateway/src/dtls.c:881: undefined reference to `srtp_crypto_policy_set_aes_gcm_128_16_auth'
/home/jf/workspace/janus/janus-gateway/src/dtls.c:882: undefined reference to `srtp_crypto_policy_set_aes_gcm_128_16_auth'
卸载掉老版本
sudo apt autoremove libsrtp2-dev
安装新版本
wget https://github.com/cisco/libsrtp/archive/v2.4.0.tar.gz
tar xvf v2.4.0.tar.gz
cd libsrtp-2.4.0/
./configure --prefix=/usr --enable-openssl
make shared_library
sudo make install
参考资料:
Ubuntu 下 Janus Server 搭建笔记 - 知乎
Janus WebRTC Server (0.x): About Janus