我孤身走在路上, 石子在雾中发亮,夜很安静,荒原面对太空,星星互诉衷肠
centos7 搭建 Freeswitch
centos7 搭建 Freeswitch

centos7 搭建 Freeswitch

Freeswitch在安装的时候还是比较麻烦,在编译时会遇到很多问题,在遇到了很多问题后,我把安装的过程整理了一下,照抄作业基本没有问题,基础环境是Centos7.9 X64,所有编译的源文件路径都在/usr/local/src下,方便你后期重新编译模块

先安装依赖

yum install -y zlib-devel openssl-devel libjpeg-turbo-devel git sqlite-devel libcurl-devel speex-devel libedit-devel ldns-devel 
yum install -y gcc gcc-c++ libtool libtiff libtiff-devel autoconf automake libtool gcc-c++ ncurses-devel make zlib-devel
yum install -y libjpeg-devel openssl-devel e2fsprogs-devel curl-devel pcre-devel speex-devel sqlite-devel
yum install -y mysql-connector-odbc.x86_64 unixODBC-devel.x86_64

这个是后面需要链接数据库相关的,如果你不用数据库可以无视

yum install -y uuid uuid-devel libatomic.x86_64
yum install -y unixODBC unixODBC-devel mysql-connector-odbc
yum install -y libuuid libuuid-devel
yum install -y autoconf automake libtool gcc-c++ ncurses-devel make zlib-devel libjpeg-devel
yum install -y openssl-devel e2fsprogs-devel curl-devel pcre-devel speex-devel sqlite-devel
yum install -y libshout-devel lame-devel libmpg123-devel

安装noarch

cd /usr/local/src/
wget http://files.freeswitch.org/freeswitch-release-1-6.noarch.rpm
yum install -y freeswitch-release-1-6.noarch.rpm

处理安装源

cd /etc/yum.repos.d/
rm -rf freeswitch*
yum clean all
yum makecache
yum -y update

安装依赖

yum install -y libatomic
yum install -y git alsa-lib-devel autoconf automake bison broadvoice-devel bzip2 curl-devel libdb4-devel e2fsprogs-devel erlang flite-devel g722_1-devel gcc-c++ gdbm-devel gnutls-devel ilbc2-devel ldns-devel libcodec2-devel libcurl-devel libedit-devel libidn-devel libjpeg-devel libmemcached-devel libogg-devel libsilk-devel libsndfile-devel libtheora-devel libtiff-devel libtool libuuid-devel libvorbis-devel libxml2-devel lua-devel lzo-devel mongo-c-driver-devel ncurses-devel net-snmp-devel openssl-devel opus-devel pcre-devel perl perl-ExtUtils-Embed pkgconfig portaudio-devel postgresql-devel python-devel python-devel soundtouch-devel speex-devel sqlite-devel unbound-devel unixODBC-devel wget which yasm zlib-devel libshout-devel libmpg123-devel lame-devel

安装cmake

cmake-3.8.2
//检查是否已有cmake,如果有的话remove掉
yum info cmake
//删除cmake版本
 yum remove cmake -y

wget https://cmake.org/files/v3.8/cmake-3.8.2.tar.gz
tar -zxvf cmake-3.8.2.tar.gz
cd cmake-3.8.2
./configure
make && make install

添加路径
vi ~/.bash_profile
将
PATH=$PATH:$HOME/bin
修改为
PATH=$PATH:$HOME/bin:/usr/local/bin
然后更新一下
source ~/.bash_profile

安装libks

cd /usr/local/src/
git clone https://github.com/signalwire/libks.git
cd libks
cmake .
make
make install

安装signalwire-c

 cd /usr/local/src/
 git clone https://github.com/signalwire/signalwire-c.git
 cd signalwire-c/
 cmake .
 make
 make install
 ln -sf /usr/local/lib64/pkgconfig/signalwire_client.pc /usr/lib64/pkgconfig/signalwire_client.pc

安装x264

cd /usr/local/src/
git clone http://git.videolan.org/git/x264.git
cd x264
./configure  --disable-asm
make && make install

安装mod_av

cd /usr/local/src/
wget http://download1.rpmfusion.org/free/el/updates/7/x86_64/x/x264-libs-0.148-24.20170521gitaaa9aa8.el7.x86_64.rpm
wget http://download1.rpmfusion.org/free/el/updates/7/x86_64/x/x264-devel-0.148-24.20170521gitaaa9aa8.el7.x86_64.rpm
rpm -hiv x264-libs-0.148-24.20170521gitaaa9aa8.el7.x86_64.rpm
rpm -hiv x264-devel-0.148-24.20170521gitaaa9aa8.el7.x86_64.rpm

安装libpng

git clone https://freeswitch.org/stash/scm/sd/libpng.git
 cd libpng
./configure
make && make install
cp /usr/local/lib/pkgconfig/libpng* /usr/lib64/pkgconfig/

安装libav

cd /usr/local/src/
git clone https://gitee.com/nwaycn/libav.git
cd libav
./configure --enable-pic --enable-shared  --enable-libx264 --enable-gpl --extra-libs="-ldl"
make && make install
cp /usr/local/lib/pkgconfig/libavcodec.pc    /usr/lib64/pkgconfig/
cp /usr/local/lib/pkgconfig/libavdevice.pc   /usr/lib64/pkgconfig/
cp /usr/local/lib/pkgconfig/libavfilter.pc   /usr/lib64/pkgconfig/
cp /usr/local/lib/pkgconfig/libavformat.pc   /usr/lib64/pkgconfig/
cp /usr/local/lib/pkgconfig/libavresample.pc /usr/lib64/pkgconfig/
cp /usr/local/lib/pkgconfig/libavutil.pc     /usr/lib64/pkgconfig/
cp /usr/local/lib/pkgconfig/libswscale.pc    /usr/lib64/pkgconfig/

cp /usr/local/lib/pkgconfig/libavcodec.pc    /usr/lib64/pkgconfig/&&cp /usr/local/lib/pkgconfig/libavdevice.pc   /usr/lib64/pkgconfig/&&cp /usr/local/lib&&pkgconfig/libavfilter.pc   /usr/lib64/pkgconfig/&&cp /usr/local/lib/pkgconfig/libavformat.pc   /usr/lib64/pkgconfig/&&cp /usr/local/lib/pkgconfig/libavresample.pc /usr/lib64/pkgconfig/&&cp /usr/local/lib/pkgconfig/libavutil.pc /usr/lib64/pkgconfig/&&cp /usr/local/lib/pkgconfig/libswscale.pc    /usr/lib64/pkgconfig/

安装opus

cd /usr/local/src/
git clone https://freeswitch.org/stash/scm/sd/opus.git
cd opus
./autogen.sh 
./configure --libdir=/home/opp/pjsiprel/lib/
make && make install

安装sofia-sip

cd /usr/local/src/
git clone https://github.com/freeswitch/sofia-sip
cd sofia-sip
./bootstrap.sh
./configure
make && make install

安装spandsp

git clone https://github.com/freeswitch/spandsp
cd spandsp
./bootstrap.sh
./configure
make && make install
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

安装libopus-devel rmp包

vim /etc/yum.repos.d/linuxtech.repo
[linuxtech]
name=LinuxTECH
baseurl=http://pkgrepo.linuxtech.net/el6/release/
enabled=1
gpgcheck=1
gpgkey=http://pkgrepo.linuxtech.net/el6/release/RPM-GPG-KEY-LinuxTECH.NET

# 创建仓库,重新安装
yum install -y libopus-devel

安装yasm

git clone https://github.com/yasm/yasm.git 
cd yasm
./autogen.sh
make && make install

安装FressSwitch,总算到安装本体了

cd /usr/local/src/ 
wget http://files.freeswitch.org/freeswitch-1.10.2.-release.tar.gz
tar vzxf freeswitch-1.10.2.-release.tar.gz
cd freeswitch-1.10.2.-release
#如果要启用odbc ./configure --enable-core-odbc-support

因为我的项目需要所以安装下列模块,MP3的模块强烈建议大家安装,WAV太占空间了,且有录音需求的话会造成大量的I/O,开启缓存会好一些,但是设备性能跟不上会有莫名的问题,例如录音掉帧,杂音等

在开始编译前现将odbc及mp3模块打开,一起编译

formats/mod_shout  #MP3文件支持模块
event_handlers/mod_odbc_cdr #话单持久化到mysql,如果要拉话单就需要

./configure
make && make install  #编译时间很长
ln -sf /usr/local/freeswitch/bin/freeswitch /usr/bin/
ln -sf /usr/local/freeswitch/bin/fs_cli /usr/bin/
  • 下面是一些帮助和提示
    freeswitch -nc -rp # 后台启动freeswitch服务
    freeswitch -nonat -nc -rp  //不检查路由穿透行,加上此参数后会启动很快
    freeswitch -stop #停止freeswitch服务
    fs_cli
    # freeswitch -help
    -help                  -- 显示本帮助信息
    -version               -- 显示版本信息
    -rp                    -- 开启高优先级(实时)设置
    
    -nosql                 -- 不使用SQL,show channels 类的命令将不能显示结果
    -nonat                 -- 如果路由器支持uPnP或NAT-PMP,则FreeSWITCH可以自动解决NAT穿越问题。如果路由器不支持,则该选项可以使启动更快
    
    -stop                  -- 关闭 FreeSWITCH,它会在run目录中查找 PID文件
    -nc                    -- 启动到后台模式,没有控制台

后续我也会陆续放出一些教程,持久化通话清单到数据库,使用minio管理录音,对接第三方网关,方便小伙伴二次开发。

2条评论

  1. Pingback:Freeswitch配置日志 - 无双的个人博客

  2. Pingback:Freeswitch配置日志 - 无双的个人博客

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

41 − 38 =