centos7编译安装freeswitch软电话交换软件并实现通话
centos7编译安装freeswitch,并实现通话
环境
centos7.9(最小安装的)
freeswitch1.10.5源码
安装
编译环境安装
由于centos7使用最小安装,需要安装的软件有点多
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 python 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
下载准备源码文件
由于github官网不能稳定访问 此处使用镜像网址github.com.cnpmjs.org,也可通过其他途径下载源码文件
cd /usr/local/src
git clone -b v1.10.5 https://github.com.cnpmjs.org/signalwire/freeswitch.git freeswitch
cd /usr/local/src/freeswitch
git clone https://github.com.cnpmjs.org/freeswitch/spandsp.git
git clone https://github.com.cnpmjs.org/freeswitch/sofia-sip.git
git clone https://github.com.cnpmjs.org/signalwire/libks.git
编译安装
#安装libks
cd /usr/local/src/freeswitch/libks
cmake3 .
make -j32
make install -j32
#安装spandsp
cd /usr/local/src/freeswitch/spandsp
./bootstrap.sh -j32
./configure
make -j32
make install -j32
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH}
ldconfig
#安装sofia
cd /usr/local/src/freeswitch/sofia-sip
./bootstrap.sh -j32
./configure
make -j32
make install -j32
ldconfig
cd /usr/local/src/freeswitch
./bootstrap.sh -j32
vim modules.conf
#根据需要注释不需要的功能
./configure --enable-portable-binary --prefix=/opt/freeswitch-test --with-gnu-ld --with-python --with-openssl --enable-core-odbc-support --enable-zrtp
make -j32
make install -j32
启动测试
#启动
/opt/freeswitch/bin/freeswitch
/opt/freeswitch/bin/freeswitch -nc #后台启动
#客户端连接
/opt/freeswitch/bin/fs_cli
注册
注册-做为落地网关
以注册到vos落地为例
1 vos新建动态落地,并记录网关名称和配置密码
2 新建freeswitch配置文件
cat /opt/freeswitch/etc/freeswitch/sip_profiles/external/test.xml
<include>
<gateway name="test01">
<param name="username" value="test01"/>
<param name="realm" value="192.168.1.2:8000"/>
<param name="from-user" value="test01"/>
<param name="from-domain" value="192.168.1.2:8000"/>
<param name="password" value="此处为配置密码"/>
<param name="extension-in-contact" value="true"/>
<param name="register" value="true"/>
<param name="expire-seconds" value="3600"/>
</gateway>
</include>
cat /opt/freeswitch/etc/freeswitch/sip_profiles/external.xml
如下部分需要自定义:
<param name="context" value="external-xxx"/>
<param name="rtp-ip" value="192.168.2.3"/>
<param name="sip-ip" value="192.168.2.3"/>
<param name="ext-rtp-ip" value="stun:xxx"/>
<param name="ext-sip-ip" value="stun:xxx"/>
3 启动fs,按f5并查看注册状态
如下,已正常注册到vos,
4 在拨号计划external-xxx中指定中继线路信息,即可将来自vos的呼叫送往指定线路。
cat /opt/freeswitch/etc/freeswitch/dialplan/ext.xml
<include>
<context name="external_ctx">
<extension name="out">
<condition field="destination_number" expression="^(\d{8}|\d{10}|\d{11})$"/>
<condition field="caller_id_number" expression="^18\d+$">
<action application="set" data="hangup_after_bridge=true"/>
<action application="bridge" data="{absolute_codec_string='PCMA',origination_caller_id_number=${caller_id_number}}sofia/gateway/${caller_id_number}/${destination_number}"/>
<action application="hangup"/>
</condition>
</extension>
</context>
</include>