1.安装coturn
ubuntu@VM-0-7-ubuntu:~$ sudo su
root@VM-0-7-ubuntu:/home/ubuntu# git clone https://github.com/coturn/coturn
2.安装一些插件。
安装插件前先更新一下
apt:apt-get update
root@VM-0-7-ubuntu:/home/ubuntu# apt-get install libssl-dev libevent-dev libpq-dev mysql-client libmysqlclient-dev libhiredis-dev make -y
root@VM-0-7-ubuntu:/home/ubuntu# apt-get install gdebi-core -y
root@VM-0-7-ubuntu:/home/ubuntu# apt-get install sqlite libsqlite3-dev -y
3.编译coturn
root@VM-0-7-ubuntu:/home/ubuntu# ls
coturn
root@VM-0-7-ubuntu:/home/ubuntu# cd coturn/
root@VM-0-7-ubuntu:/home/ubuntu/coturn# ./configure --prefix=/usr/local/coturn
然后make:
root@VM-0-7-ubuntu:/home/ubuntu/coturn# make
然后安装:
root@VM-0-7-ubuntu:/home/ubuntu/coturn# make install
4.修改配置:
root@VM-0-7-ubuntu:/home/ubuntu/coturn# cd /usr/local/coturn/
root@VM-0-7-ubuntu:/usr/local/coturn# ls
bin etc include lib man share var
root@VM-0-7-ubuntu:/usr/local/coturn# cd etc/
root@VM-0-7-ubuntu:/usr/local/coturn/etc# ls
turnserver.conf.default
root@VM-0-7-ubuntu:/usr/local/coturn/etc# cp turnserver.conf.default turnserver.conf root@VM-0-7-ubuntu:/usr/local/coturn/etc# ls
turnserver.conf turnserver.conf.default
root@VM-0-7-ubuntu:/usr/local/coturn/etc# vim turnserver.conf
修改:
①开启端口
②改成服务器外网IP:
③配置用户名和密码:
然后保存退出。
5.启动
(会提示先安装coturn或turnsever命令,根据提示安装:sudo apt install coturn
然后输入启动命令:
ubuntu@VM-0-7-ubuntu:~$ turnserver -v -r 129.204.22.211 -a -o -c /usr/local/coturn/etc/turnserver.conf
6.测试
网址:
https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/
①填写外网IP 账户 密码:
②出现done表示安装成功