目录
一、有一台公网IP的云主机
腾讯云可以免费领取一台15天的云服务,地址:https://cloud.tencent.com/act/free?from=11649,
二、安装coturn的依赖组件
yum install openssl-devel
yum install libevent2
yum install libevent-devel
三、下载coturn源码并编译
各个版本的网址:https://coturn.net/turnserver/或者https://github.com/coturn/coturn
wget https://github.com/coturn/coturn/archive/4.5.1.1.tar.gz
tar -zxvf 4.5.1.1.tar.gz
cd coturn-4.5.1.1
./configure --prefix=/usr/local/coturn
make & make install
演示如下:
本人是在根目录的home文件下面创建coturn文件夹存放下载下来的coturn的安装包的
进入coturn解压文件夹中执行上部命令:
./configure --prefix=/usr/local/coturn (prefix为指定安装目录)
make编译
make install安装
成功后,可以cd /usr/local/coturn查看
四、修改coturn服务器配置文件
1)把本地下载的coturn的安装包解压
打开 turnserver-4.5.0.8\examples\etc下的turnserver.conf文件进行编辑
修改一下内容:
1)listening-port=3478 #监听端口(默认即可)
2)external-ip=60.70.80.91 #服务器公网IP地址
3)user=ceshi:123456 #访问服务器的用户名密码
4)realm=xxx.xxx.cn/com... #服务器域名
5)修改cli-password
6)修改cert和pkey的引进路径
2)然后把编辑好的turnserver.conf和该文件下的turn_server_cert.pem文件和turn_server_pkey.pem上传到/usr/local/coturn/etc的文件夹
3)配置完成保存退出,使用如下命令启动
./bin/turnserver -c ./etc/turnserver.conf -o(此命令为后台启动,不占用窗口)
五、测试
测试turn服务,网址:https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/
六、常见问题
问题1:
install is /usr/bin/install
pkill is /usr/bin/pkill
sqlite3 is /usr/bin/sqlite3
Use TMP dir /var/tmp
Compiler: unknown
ERROR: cannot use compiler unknown properly
错误原因:gcc未安装或gcc版本过低
解决方法:
升级gcc
yum install gcc gcc-c++
问题2:
[root@10-10-128-155 coturn]# ./configure
install is /usr/bin/install
pkill is /usr/bin/pkill
sqlite3 is /usr/bin/sqlite3
Use TMP dir /var/tmp
Compiler: cc
Library option -lsocket cannot be used
Library option -lwldap32 cannot be used
Library option -lwldap64 cannot be used
Library option -lintl cannot be used
Sockets code is fine: no sin_len field present
Ignore IP_RECVERR
Library option -lcrypto cannot be used
ERROR: OpenSSL Crypto development libraries are not installed properly in required location.
Abort.
解决方案:
需要依赖openssl库
yum install openssl-devel
问题3:
CONFIG ERROR: Empty cli-password, and so telnet cli interface is disabled! Please set a non empty cli-password!
解决方案:
在配置文件/usr/local/etc/turnserver.conf中,添加cli-password字段