coturn 在云服务器上安装配置和运行

1.先安装libevent

sudo apt install libevent-dev

2.下载和安装coturn

git clone https://github.com/coturn/coturn.git

或者

wget https://github.com/coturn/coturn/archive/4.5.1.1.tar.gz

解压后,配置和安装如下

cd coturn  // 切换到coturn文件中
sudo ./configure –prefix=/usr/local/coturn   // 安装路径perfix, 生成makefile
make
sudo make install

如果安装中出现问题 ,报一个类似undefined reference to `SSL_CTX_up_ref的错误,请用

wget https://github.com/coturn/coturn/archive/4.5.1.1.tar.gz这个包,不要用第一个包

将所有的.pem文件copy到/etc下面,将example下面的turnserver.conf copy到/etc下面。

配置turnserver.conf 中的如下项目

listening-port=3478 // 这个端口号是默认的 external-ip=47.**.**.81 // 此ip为云服务器公网ip user=dyx:*** // 这个是用户名:密码 realm=dyx.***r.com // 这里填写域名,没有域名的情况下也可以填云服务器公网ipcli-password:****** //这个不配置会报错

turnserver -o -a -f -user=admin:123456 -c /etc/turnserver.conf -r Harbin
-o 是让程序在后台启动
-r 后面填个地区就行。
-user 一定要和配置文件中一样。
也可以直接运行
 turnserver -c /etc/turnserver.conf

查看3478端口是否被占用,云服务器要打开相应的端口,如下图

测试:

登录下面的网址

https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/

其中182.61.26.183是云服务器公网ip地址,点就Gather candidates能得到上图的adress列表,表示coturn服务器运行正常。

经验分享 程序员 微信小程序 职场和发展