FreeSWITCH学习(一)——CentOS下源码编译安装FreeSWITCH

前言

最近这段时间因为项目原因,开始学习FreeSWITCH。IP电话这个领域以前没接触过,光是理解一些概念都花了不少时间。准备记录一下自己的学习成果。

关于FreeSWITCH,具体的概念我也不细说了,我本身也不是搞这个领域出身的,理解并不透彻。对于搞计算机的人来说,就粗略理解为其功能像路由器、交换机之类的。总之一个ip电话需要通过这个软件,打给别的ip电话,或者通过例如sip服务器等方式和我们现有的固化和移动电话进行通话。

 

安装FreeSWITCH

FreeSWITCH是一个跨平台的软件,我在windows上和centos上都进行安装。在windows上安装的,只需要在https://files.freeswitch.org/地址下寻找windows版的安装即可。关于linux版,我是通过https://files.freeswitch.org/下载了源码进行编译安装的。本次使用freeswitch-1.10.5.-release版本。

源码进行编译的步骤。

./configure  -C --enable-core-odbc-support
make
make install

这个步骤非常简单,但是通常存在一大堆坑,所以我建议先把本文后面提及的依赖都安装上,免得反复编译,毕竟freeSWITCH编译一把也挺费时间的。

 

执行./configure遇到的问题

缺少C++编译器

在执行./configure中,有可能会提示缺少c++的编译器。这时候需要先安装c++编译器,这里选择gcc

yum -y install gcc
yum -y install gcc-c++

 

需要安装spandsp3和sofia-sip

在执行./configure中,遇到类似下图的错误

安装spandsp,首先从git上下载https://github.com/freeswitch/spandsp.git。然后执行

./bootstrap.sh -j
./configure
make
make install
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH}
ldconfig

我在执行./bootstrap.sh -j还是报错,意思是缺少libtoolize,这个我们还需要安装libtool

yum install libtool

接着执行./configure时分别报缺少libtiff-devel和libjpeg-devel,因此我们又需要安装

yum install libtiff-devel
yum install libjpeg-devel

 

接着安装sofia-sip,首先下载源码https://github.com/freeswitch/sofia-sip.git,之后执行:

./bootstrap.sh -j
./configure
make
make install
ldconfig

在make的过程中遇到缺少找不到openssl/ssl.h这个头文件,如下图:

FreeSWITCH学习(一)——CentOS下源码编译安装FreeSWITCH_第1张图片

我们需要安装OpenSSL的开发包

yum install openssl-devel

 

缺少其他的依赖

除了上面两个之外,其他缺少的依赖都可以直接通过yum install解决,我添加过这些依赖

yum install sqlite-devel
yum install libcurl-devel
yum install pcre
yum install pcre-devel
yum install speex
yum install speex-devel
yum install ldns-devel libidn-devel unbound-devel
yum install libedit-devel

 

执行make遇到的问题

缺少yasm

# wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
# tar zxvf yasm-1.3.0.tar.gz
# cd yasm-1.3.0
# ./configure
# make && make install

 

缺少libavformat-dev

git clone https://freeswitch.org/stash/scm/sd/libav.git
#或者 wget https://freeswitch.org/stash/rest/api/latest/projects/SD/repos/libav/archive?format=zip
cd libav
./configure
make
make install

如果下载速度太慢,可以用迅雷下载https://freeswitch.org/stash/rest/api/latest/projects/SD/repos/libav/archive?format=zip后再上传服务器。

 

找不到lua.h文件

yum install lua lua-devel

缺少opus-devel

yum -y install opus-devel

如果之后make还是不行,考虑通过rpm -qa | grep opus查找是否安装。有安装的话,通过rpm -e命令卸载,然后使用源码编译

wget https://archive.mozilla.org/pub/opus/opus-1.3.1.tar.gz
./configure
make
make install
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH}
ldconfig

 

缺少libpq-dev

yum install postgresql-devel

 

缺少libks

先安装cmake

wget https://cmake.org/files/v3.13/cmake-3.13.3.tar.gz
tar -zxvf cmake-3.13.3.tar.gz
cd cmake-3.13.3 
./bootstrap
gmake
make install
ln -s /usr/local/bin/cmake /usr/bin 

安装libatomic.so

yum -y install *atomic*

 

接着安装libks

git clone https://github.com/signalwire/libks.git
cd libks
cmake .   #(注意,这里有个“.”,表示当前目录)
make
make install

 

缺少signalwire-client-c

git clone https://github.com/signalwire/signalwire-c.git
cd signalwire-c
cmake .
make
make install

缺少yum install libsndfile-devel

yum install libsndfile-devel

 

安装声音文件

缺少声音文件,拨打测试9664的时候会直接挂断。通过这两个命令可以获取

make cd-sounds-install
make cd-moh-install

我这里服务器下载声音文件慢得令人发指,所以我通过迅雷下载了再上传到服务器上。声音文件的地址是以下这些,全都要下载:

http://files.freeswitch.org/releases/sounds/freeswitch-sounds-en-us-callie-8000-1.0.52.tar.gz
http://files.freeswitch.org/releases/sounds/freeswitch-sounds-en-us-callie-16000-1.0.52.tar.gz
http://files.freeswitch.org/releases/sounds/freeswitch-sounds-en-us-callie-32000-1.0.52.tar.gz
http://files.freeswitch.org/releases/sounds/freeswitch-sounds-en-us-callie-48000-1.0.52.tar.gz
http://files.freeswitch.org/releases/sounds/freeswitch-sounds-music-8000-1.0.52.tar.gz
http://files.freeswitch.org/releases/sounds/freeswitch-sounds-music-16000-1.0.52.tar.gz
http://files.freeswitch.org/releases/sounds/freeswitch-sounds-music-32000-1.0.52.tar.gz
http://files.freeswitch.org/releases/sounds/freeswitch-sounds-music-48000-1.0.52.tar.gz

 

启动FreeSWITCH

一般FreeSWITCH会被安装到/usr/local/freeswitch目录下,启动FreeSWITCH并让其在后台运行:

/usr/local/freeswitch/bin/freeswitch -nc

 

x-lite安装

我们要测试一下安装的FreeSWITCH是否已生效。在windows下安装x-lite,这是一个软电话,可以连上FreeSWITCH。x-lite直接到官网下载即可https://x-lite.en.softonic.com/,然后进行安装。

启动x-lite后设置“SIP Account Setting”按钮,按add一条记录了:

FreeSWITCH学习(一)——CentOS下源码编译安装FreeSWITCH_第2张图片

之后拨打9664,如果听到音乐,则表示成功。

你可能感兴趣的:(FreeSWITCH)