文章目录
- 前言
- 一、环境
- 二、安装依赖
- 三、下载源码
- 四、编译
- 1. 编译必需库
- 2. 修改module.conf
- 3. 编译freeswitch
- 五、验证
- 1. 启动freeswitch
- 2. 验证必要端口是否启动
- 六、常见编译问题
- 总结
前言
freswitch在centos7下编译总体上还是不难的,但一些看似很难实则很容易甚至不需要解决的问题往往会”欺负“一些初学者(比如说本人);本文主要介绍centos 7下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
四、编译
1. 编译必需库
首先,要先编译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
2. 修改module.conf
下面则是安装freeswitch, 由于freeswitch支持动态编译和动态加载,一些不需要的模块可以不编译,如:mod_signalwire、mod_av,修改方法:
找到module.conf文件,找到mod_signalwire和mod_av注释掉,修改如下:
#applications/mod_signalwire
#applications/mod_av
3. 编译freeswitch
有了前两步的准备,编译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并验证可用性了。
首先
1. 启动freeswitch
cd /usr/local/freeswitch/bin
./freeswitch -nonat
启动成功:
2. 验证必要端口是否启动
检查5060、5066、8021等端口是否启动(还有其他端口,但现在只需要看这几个端口就可以证明freeswitch启动正常了)。
netstat -anp |grep freeswitch
另外,可以软电话注册到freeswitch验证,这里不再赘述。
六、常见编译问题
首先,谨记的是先安装依赖,可以解决90%以上的编译问题!
1.checking for spandsp >= 3.0… configure: error: no usable spandsp; please install spandsp3 devel package or equivalent
这个问题是缺少依赖库spandsp, 安装方法参见本文步骤《 四、编译->2. 修改module.conf》。
2.checking for sofia-sip-ua >= 1.13.6… configure: error: no usable sofia-sip; please install sofia-sip-ua devel package or equivalent
这个是由于缺少依赖库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在centos 7下的编译过程,和一些常见的编译问题及其解决办法