freswitch在centos7下编译总体上还是不难的,但一些看似很难实则很容易甚至不需要解决的问题往往会”欺负“一些初学者(比如说本人);本文主要介绍centos7下freeswitch的编译过程,和常见的编译中问题及解决方法。
centos 7.6
freeswitch 1.10.7
freeswitch的依赖非常多,如果不安装依赖就开始编译freeswitch,那就遇到更多的问题,安装依赖之后,可以解决90%以上的问题。
安装依赖命令如下:
yum install -y https://files.freeswitch.org/repo/yum/centos-release/freeswitch-release-repo-0-1.noarch.rpm epel-release
yum install -y yum-utils --enablerepo=extras
yum install -y yum-plugin-ovl centos-release-scl rpmdevtools yum-utils git wget vim devtoolset-7-gcc* devtoolset-7 libtiff-devel cmake3 libatomic unixODBC unixODBC-devel.x86_64 postgresql-libs postgresql-devel libpqxx-devel
yum install -y gcc-c++ autoconf automake libtool ncurses-devel zlib-devel libjpeg-devel openssl-devel e2fsprogs-devel sqlite-devel libcurl-devel pcre-devel speex-devel ldns-devel libedit-devel libxml2-devel libyuv-devel libvpx-devel libvpx2* libdb4* libidn-devel unbound-devel libuuid-devel lua-devel libsndfile-devel yasm-devel
freeswitch下载地址: https://github.com/signalwire/freeswitch.git
另外有两个比较重新的库需要手动安装,分别是spandsp和sofia-sip
下载命令:
cd /data
git clone -b v1.10.7 https://github.com/signalwire/freeswitch
cd /data/freeswitch
git clone https://github.com/freeswitch/spandsp.git
git clone https://github.com/freeswitch/sofia-sip.git
首先,要先编译spandsp和sofia-sip, 否则freeswitch在configure阶段会报错。
#编译spandsp
cd /data/freeswitch/spandsp
./bootstrap.sh
./configure
make
make install
#编译sofia-sip
cd /data/freeswitch/sofia-sip
./bootstrap.sh
./configure
make
make install
#添加库的路径到系统
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH}
ldconfig
下面则是安装freeswitch, 由于freeswitch支持动态编译和动态加载,一些不需要的模块可以不编译,如:mod_signalwire、mod_av,修改方法:
找到module.conf文件,找到mod_signalwire和mod_av注释掉,修改如下:
#applications/mod_signalwire
#applications/mod_av
有了前两步的准备,编译freeswitch基本就不会遇到问题了,命令如下:
cd /data/freeswitch
./bootstrap.sh
./configure --enable-portable-binary --prefix=/usr/local/freeswitch --with-gnu-ld --with-python --with-openssl --enable-core-odbc-support --enable-zrtp
make
make install
freeswitch安装完成之后,下一步就是启动freeswitch并验证可用性了。
首先
cd /usr/local/freeswitch/bin
./freeswitch -nonat
启动成功:

检查5060、5066、8021等端口是否启动(还有其他端口,但现在只需要看这几个端口就可以证明freeswitch启动正常了)。
netstat -anp |grep freeswitch

另外,可以软电话注册到freeswitch验证,这里不再赘述。
首先,谨记的是先安装依赖,可以解决90%以上的编译问题!


这个是由于缺少依赖库sofia-sip,安装方法参见本文步骤《 四、编译->2. 修改module.conf》。
3. *** You must install signalwire-client-c to build mod_signalwire. Stop.

报错的是mod_signalwire, 这个模块怎么看也是不需要的,注释掉它,注释方法在本文步骤《四、编译-> 1.编译必需库》。
4. **** You must install libavformat-dev and libswscale-dev to build mod_av. Stop.

由于项目没有用到mod_av模块,选择注释掉,注释方法在本文步骤《四、编译-> 1.编译必需库》。
本文介绍freeswitch在centos7下的编译过程,和一些常见的编译问题及其解决办法。如果觉得有帮助,可以关注一下博主~