官网地址:https://github.com/coturn/coturn
Centos7 安装coturn部署一套 STUN/TURN 服务 webRTC打洞服务器
1、安装相关依赖
yum install -y make gcc cc gcc-c++ wget openssl-devel libevent libevent-devel
2、下载可以编译的源码包
官方下载地址:Downloads · coturn/coturn Wiki · GitHub
这里我们下载最新的4.5.0.8
wget https://coturn.net/turnserver/v4.5.0.8/turnserver-4.5.0.8.tar.gz
解压并进入目录
tar -zxvf turnserver-4.5.0.8.tar.gz
cd turnserver-4.5.0.8/
3、编译安装
./configure --prefix=/usr/local/turnserver # 指定安装的目录
make && make install
安装完成后打印内容:
cp -rpf include/turn/client /usr/local/turnserver/include/turn
install include/turn/ns_turn_defs.h /usr/local/turnserver/include/turn
cat /usr/local/turnserver/share/doc/turnserver/postinstall.txt
==================================================================1) If your system supports automatic start-up system daemon services,
then to enable the turnserver as a system service that is automatically
started, you have to:a) Create and edit /etc/turnserver.conf or /usr/local/etc/turnserver.conf . Use /usr/local/etc/turnserver.conf.default as an example.b) For user accounts settings: set up SQLite or PostgreSQL or MySQL or MongoDB or Redis database for user accounts.Use /usr/local/share/turnserver/schema.sql as SQL database schema,or use /usr/local/share/turnserver/schema.userdb.redis as Redisdatabase schema description and/or /usr/local/share/turnserver/schema.stats.redisas Redis status & statistics database schema description.If you are using SQLite, the default database location is in /var/db/turndb or in /usr/local/var/db/turndb or in /var/lib/turn/turndb.c) add whatever is necessary to enable start-up daemon for the /usr/local/bin/turnserver.2) If you do not want the turnserver to be a system service, then you can start/stop it "manually", using the "turnserver" executable with appropriate options (see the documentation).3) To create database schema, use schema in file
/usr/local/share/turnserver/schema.sql.4) For additional information, run:$ man turnserver$ man turnadmin$ man turnutils==================================================================
4、设置环境变量
编辑root目录下.bashrc文件 vi ~/.bashrc
插入一下内容
export turnserver_home=/usr/local/turnserver
export PATH=$PATH:$turnserver_home/bin
5、编辑配置文件
先找到配置文件位置
find /usr -name turnserver.conf
#编辑配置文件
vim /usr/local/turnserver/share/examples/turnserver/etc/turnserver.conf
在配置文件末尾加入一下内容
listening-port=3478 # 监听的端口
### listening-ip=x.x.x.x # 监听的内网IP
external-ip=x.x.x.x # 监听的外网IP (如果在云主机)指定云主机的公网IP地址
user=user:123456 # 设置账号密码
6、指定配置文件启动服务
turnserver -v -r 外网ip -a -o -c /usr/local/turnserver/share/examples/turnserver/etc/turnserver.conf
注意:如果使用的是阿里云或腾讯云的服务器,要开发对应端口的访问,关闭对应端口的防火墙
测试是否配置成功
https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/
————————————————
版权声明:本文为CSDN博主「haeasringnar」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/haeasringnar/article/details/94607464