AppRTC搭建
安装JDK
$ yum install -y java-1.8.0-openjdk
$ java -version
openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_222-b10)
OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)
安装Node.js
$ yum install -y nodejs
# npm是nodejs的包管理器,随nodejs一同安装
$ npm -g install grunt-cli
$ node --version
v6.17.1
$ npm --version
3.10.10
$ grunt --version
grunt-cli v1.3.2
安装Python和Python-webtest
$ yum install -y python
$ yum install -y python-webtest
$ python --version
Python 2.7.5
安装google_appengine
$ wget https://storage.googleapis.com/appengine-sdks/featured/google_appengine_1.9.40.zip
$ unzip google_appengine_1.9.40.zip
-bash: unzip: command not found
$ yum install -y unzip
$ unzip google_appengine_1.9.40.zip
$ ls
google_appengine google_appengine_1.9.40.zip
配置环境变量:在/etc/profile文件最后增加一行:
export PATH=$PATH:/root/webrtc/google_appengine
然后刷新:
$ source /etc/profile
安装go
$ yum install -y golang
$ go version
go version go1.13.1 linux/amd64
创建go工作目录
$ mkdir -p /root/webrtc/goWorkspace/src
配置环境变量:在/etc/profile文件最后增加一行:
export GOPATH=/root/webrtc/goWorkspace
$ source etc/profile
安装libevent
$ wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
$ tar xvfz libevent-2.0.21-stable.tar.gz
$ cd libevent-2.0.21-stable
$ ./configure
$ make
$ make install
安装apprtc
$ git clone https://github.com/webrtc/apprtc.git
$ ln -s /root/webrtc/apprtc/src/collider/collider $GOPATH/src
$ ln -s /root/webrtc/apprtc/src/collider/collidermain $GOPATH/src
$ ln -s /root/webrtc/apprtc/src/collider/collidertest $GOPATH/src
$ go get collidermain
$ go install collidermain
安装coturn
$ wget https://coturn.net/turnserver/v4.5.0.8/turnserver-4.5.0.8.tar.gz
$ tar xvfz turnserver-4.5.0.8.tar.gz
$ cd turnserver-4.5.0.8
$ ./configure
$ make
$ make install
coturn Nat穿透服务器
$ nohup turnserver -L xxx.xxx.xxx.xxx -a -u damon:12345 -v -f -r netease &
$ netstat -ntulp | grep turnserver
collider 信令服务器
$ mkdir /cert
$ cd /cert
$ openssl genrsa -out key.pem 2048
$ openssl req -new -x509 -key key.pem -out cert.pem -days 1095
$ nohup $GOPATH/bin/collidermain -port=8089 -tls=true -room-server="https://xxx.xxx.xxx.xxx:8080" &
$ netstat -ntulp | grep collider
apprtc 房间服务器
$ cd /root/webrtc/apprtc
#安装依赖
$ npm install
#编译
$ grunt build
#检查
$ netstat -ntulp | grep 8080
nginx
#下载nginx
$ wget http://nginx.org/download/nginx-1.17.4.tar.gz
$ cd nginx-1.17.4
$ ./configure --with-http_ssl_module
$ make install
#默认安装在/usr/local/nginx
$ vim /usr/local/nginx/conf/nginx.conf
配置文件内容:
events {
worker_connections 1024;
}
http{
upstream roomserver {
server xxx.xxx.xxx.xxx:8080;
}
server {
listen 80;
server_name xxx.xxx.xxx.xxx;
return 301 https://$server_name$request_uri;
}
server {
root /usr/share/nginx/html;
index index.php index.html index.htm;
listen 443 ssl;
ssl_certificate /cert/cert.pem;
ssl_certificate_key /cert/key.pem;
server_name xxx.xxx.xxx.xxx;
location / {
proxy_pass http://roomserver$request_uri;
proxy_set_header Host $host;
}
location ~ .php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
}
跨域问题报错:Failedto start signaling:Failedto execute'pushState' on'History'
解决方法:vim /root/webrtc/apprtc/out/app_engine/js/apprtc.debug.js
AppController.prototype.pushCallNavigation_=function(roomId, roomLink){ if(!isChromeApp()){ //增加下面这行 roomLink=roomLink.substring("http","https"); window.history.pushState({"roomId":roomId, "roomLink":roomLink}, roomId, roomLink); } };