----------------------------------------------------------------------------------------------------------------------
一分鐘快速搭建 rtmpd 服務器: https://blog.csdn.net/freeabc/article/details/102880984
軟件下載地址: http://www.qiyicc.com/download/rtmpd.zip
github 地址:https://github.com/superconvert/smart_rtmpd
----------------------------------------------------------------------------------------------------------------------
操作系統 Ubuntu 18.04 64 位, Janus 和 Mediasoup 都是性能非常不錯的 webrtc 服務器,相對比較簡易,下面是我親自驗證並能成功編譯運行的流程,分享給大家
1. 安裝 libnice
git clone https://gitlab.freedesktop.org/libnice/libnice
問題解決
https://blog.csdn.net/ewerwerwerer/article/details/107936762
這個錯誤是meson版本不匹配導致的,ubuntun18.04中的meson版本爲0.45.1, libnice中用了更新的meson版本,所以就想着在ubuntu18.04中更新meson的版本。
但是apt中meson的最新版本號就是0.45.1 通過 pip3 install --user meson 安裝最新的 meson , 繼續搜索發現pip3會將軟件安裝到/home/user/.local/bin
而系統默認是使用/usr/bin/meson 所以通過修改path路徑使得pip安裝的meson優先於系統meson被搜索到 export PATH=~/.local/bin:$PATH
安裝 gnutls
aptitude install libgnutls28-dev
安裝 gstreamer
aptitude install libgstreamer1.0-dev
安裝 meson
apt install meson
安裝 pip
apt install python3-pip
更新 meson 爲最新版本
pip3 install --user meson
export PATH=~/.local/bin:$PATH
meson -v 查看版本,是否是最新版本,否則無法編譯 libice
開始編譯 libice
cd libnice
meson build
ninja -C build
ninja -C build test
ninja -C build install
2. 安裝 libwebsocket
git clone https://github.com/warmcat/libwebsockets.git
aptitude install libssl-dev
mkdir build
cd build/
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_C_FLAGS="-fpic" ..
make
sudo make install
3. 安裝 nodejs
wget https://nodejs.org/dist/v14.8.0/node-v14.8.0-linux-x64.tar.xz
tar -xJf node-v14.8.0-linux-x64.tar.xz -C /opt
sudo ln -s /opt/node-v14.8.0-linux-x64/bin/npm /usr/local/bin/npm
sudo ln -s /opt/node-v14.8.0-linux-x64/bin/node /usr/local/bin/node
node -v
sudo npm -g install http-server
4. 安裝 libsrtp/archive/v2
wget https://github.com/cisco/libsrtp/archive/v2.1.0.tar.gz
tar xfv v2.1.0.tar.gz
cd libsrtp-2.1.0
./configure --prefix=/usr --enable-openssl
make shared_library && sudo make install
5. 編譯 janus
git clone https://github.com/meetecho/janus-gateway.git
aptitude install libconfig-dev
aptitude install libjansson-dev
aptitude install gengetopt
aptitude install libmicrohttpd-dev
cd janus-gateway/
./autogen.sh
./configure --prefix=/opt/janus --enable-websockets --enable-http
make
sudo make install
make configs
/opt/janus/bin/janus --debug-level=7 --log-file=$HOME/janus-log
6. 製作測試證書
編制腳本 make_cert.sh 製作私有證書
!/bin/sh
openssl genrsa -out privkey.pem 1024
openssl req -new -x509 -key privkey.pem -out server.pem -days 365
7. 安裝 nginx
apt install nginx
拷貝 janus 演示頁面到 /opt/html 下
mkdir /opt/html
cp /root/work/janus-gateway/html/* /opt/html/ -r
編輯 vi /etc/nginx/nginx.conf
http {
server {
listen 0.0.0.0:443 ssl;
listen [::]:443 ssl;
# tls configuration that is not covered in this guide
# we recommend the use of https://certbot.eff.org/
server_name doman.com;
# janus 的演示頁面
root /opt/html;
index index.html;
location ~ ^/([a-zA-Z0-9=\?]+)$ {
rewrite ^/(.*)$ / break;
}
location / {
ssi on;
}
# 證書的路徑
ssl_certificate /root/work/cert/server.pem;
ssl_certificate_key /root/work/cert/privkey.pem;
}
}
8. 配置 janus
vi /opt/janus/etc/janus/janus.transport.http.jcfg
general: {
#events = true # Whether to notify event handlers about transport events (default=true)
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 = false # Whether to enable the plain HTTP interface
port = 8088 # Web server HTTP port
#interface = "eth0" # Whether we should bind this server to a specific interface only
#ip = "192.168.0.1" # Whether we should bind this server to a specific IP address (v4 or v6) only
# 這個地方需要開啓
https = true # Whether to enable HTTPS (default=false)
secure_port = 8089 # Web server HTTPS port, if enabled
#secure_interface = "eth0" # Whether we should bind this server to a specific interface only
#secure_ip = "192.168.0.1" # Whether we should bind this server to a specific IP address (v4 or v6) only
#acl = "127.,192.168.0." # Only allow requests coming from this comma separated list of addresses
}
certificates: {
# 證書需要配置
cert_pem = "/root/work/cert/server.pem"
cert_key = "/root/work/cert/privkey.pem"
#cert_pwd = "secretpassphrase"
#ciphers = "PFS:-VERS-TLS1.0:-VERS-TLS1.1:-3DES-CBC:-ARCFOUR-128"
}
9. 運行
運行 nginx
service nginx restart
運行 janus
/opt/janus/bin/janus --debug-level=7 --log-file=$HOME/janus-log
10. 測試
http://ip:port/index.html
這樣就可以體驗 janus 了, good luck!