preloader
blog-post

Debian安装FreeSWITCH 1.10.6 及mod_av、mod_cv及使用mariadb作为core数据库

author image

  源于有人以前就问如何把FreeSWITCH的运行时数据库给存于mysql中,而以前我们用的postgresql比较多,但是对于实时运行库,作为我们来说因为有各式各样针对呼叫系统的辅助的系统等在服务,用不着那样连,但对于广大FreeSWITCH使用者来说,有些人还是希望能够获得这样的能力的。所以试验并撰写此文。

一、安装 安装依赖包 在系统中先安装各式的依赖或编译环境包,在编译时,使用make -j 4 中4代表是有4核的cpu

#以下为debian 9

wget -O - https://files.freeswitch.org/repo/deb/debian-release/fsstretch-archive-keyring.asc | apt-key add -

echo "deb http://files.freeswitch.org/repo/deb/debian-release/ stretch main" > /etc/apt/sources.list.d/freeswitch.list
echo "deb-src http://files.freeswitch.org/repo/deb/debian-release/ stretch main" >> /etc/apt/sources.list.d/freeswitch.list

apt-get update
apt-get build-dep freeswitch

#以下为debian10
apt-get update && apt-get install -yq gnupg2 wget lsb-release
wget -O - https://files.freeswitch.org/repo/deb/debian-release/fsstretch-archive-keyring.asc | apt-key add -

echo "deb http://files.freeswitch.org/repo/deb/debian-release/ `lsb_release -sc` main" > /etc/apt/sources.list.d/freeswitch.list
echo "deb-src http://files.freeswitch.org/repo/deb/debian-release/ `lsb_release -sc` main" >> /etc/apt/sources.list.d/freeswitch.list

apt-get update
 

apt-get build-dep freeswitch

先下载fs

cd /opt/

git clone -b v1.10.6 https://gitee.com/nwaycn/freeswitch.git

cd freeswitch

./bootstrap.sh

先配置PKG_CONFIG_PATH

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
Fdk-aac
cd /opt/freeswitch/libs
git clone --depth 1 git://github.com/mstorsjo/fdk-aac.git
cd fdk-aac
autoreconf -fiv
./configure --disable-shared --with-pic
make && make install
h264
#git clone https://code.videolan.org/videolan/x264.git   #./bootstrap.sh
cd /opt/freeswitch/libs
git clone https://gitee.com/nwaycn/x264.git
cd x264

./configure --enable-shared –enable-static --disable-asm  
sudo make
sudo make install
ffmpeg
#git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
cd /opt/freeswitch/libs
git clone https://gitee.com/mirrors/ffmpeg.git
cd ffmpeg

#这里需要注意 av_init_packet已被废弃,可以尝试用 但是可以通过把/usr/local/include/libavcodec/packet.h 中 void av_init_packet(AVPacket *pkt);前的deprecated去掉,让其可以继续使用 复杂点的,编译时支持更多编解码


./configure   --enable-gpl   --enable-version3  --enable-nonfree --disable-static --enable-shared --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages  --enable-zlib --enable-iconv --enable-libx264 --enable-libmp3lame  --enable-libfdk-aac --enable-pic

make -j 4 && make install
安装mariadb
apt-get install mariadb-server libmariadb-dev mariadb-client

当然可能安装不成功,原来用的源提示完成不了安装,就换了个新源

vi /etc/apt/sources.list ,安装机为buster,应是debian10,此处由读者自己处理

deb https://mirror.sjtu.edu.cn/debian/ buster main contrib non-free
deb https://mirror.sjtu.edu.cn/debian/ buster-updates main contrib non-free
deb https://mirror.sjtu.edu.cn/debian/ buster-backports main contrib non-free
deb https://mirror.sjtu.edu.cn/debian-security/ buster/updates main contrib non-free

deb-src https://mirror.sjtu.edu.cn/debian/ buster-updates main contrib non-free
deb-src https://mirror.sjtu.edu.cn/debian/ buster-backports main contrib non-free
deb-src https://mirror.sjtu.edu.cn/debian/ buster main contrib non-free
deb-src https://mirror.sjtu.edu.cn/debian-security/ buster/updates main contrib non-free

安装完后,mariadb会自动启动

然后

mysql -uroot -p
MariaDB [(none)]> use mysql;  
MariaDB [mysql]> UPDATE user SET password=password('Nway123') WHERE user='root';

那么我们使用 mysql -uroot -p 就应可以连接上去了

然后创建freeswitch数据库

MariaDB [(none)]> create database freeswitch;

那么就创建成功了

安装opencv

注意

这里需要g++的版本高些,cmake需要安装

`yum install cmake

编译

cd /opt/freeswitch/libs
git clone https://gitee.com/nwaycn/opencv.git /opt/freeswitch/libs/opencv

cd /opt/freeswitch/libs/opencv
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j 8 && make install


sofia-sip
cd /opt/freeswitch/libs

git clone https://gitee.com/nwaycn/sofia-sip.git

cd sofia-sip/

sh autogen.sh

./configure --with-pic

make && make install



spandsp
cd /opt/freeswitch/libs

git clone https://gitee.com/nwaycn/spandsp.git      

cd spandsp

./bootstrap.sh

./configure --with-pic

make && make install

只处理需要的模块

修改modules.conf为以下,当然如果不需要postgresql的支持就把它去掉,去掉 mod_pgsql ,mod_signalwire 等

vim /opt/freeswitch/modules.conf

applications/mod_av
applications/mod_cv
applications/mod_blacklist
applications/mod_callcenter

applications/mod_commands
applications/mod_conference

applications/mod_db

applications/mod_dptools

applications/mod_enum
applications/mod_esf

applications/mod_expr
applications/mod_fifo

applications/mod_fsv
applications/mod_hash

applications/mod_httapi
 
applications/mod_sms
 
applications/mod_spandsp
 
applications/mod_valet_parking

 
applications/mod_voicemail
 
codecs/mod_amr
 
codecs/mod_b64

codecs/mod_g723_1
codecs/mod_g729
codecs/mod_h26x
 
codecs/mod_opus
#这里需要二选一,别都一起编译,会折腾自己
databases/mod_mariadb
 
#databases/mod_pgsql
dialplans/mod_dialplan_asterisk
 
dialplans/mod_dialplan_xml
 
endpoints/mod_rtc
 
endpoints/mod_skinny
endpoints/mod_sofia
endpoints/mod_verto
 
event_handlers/mod_cdr_csv
 

#event_handlers/mod_cdr_pg_csv
event_handlers/mod_cdr_sqlite
 
event_handlers/mod_event_socket
event_handlers/mod_fail2ban
 
formats/mod_local_stream
formats/mod_native_file
formats/mod_png
 
formats/mod_sndfile
 
formats/mod_tone_stream
 
languages/mod_lua
 
loggers/mod_console
 
loggers/mod_logfile
loggers/mod_syslog
 
xml_int/mod_xml_cdr
xml_int/mod_xml_curl
 
xml_int/mod_xml_rpc
xml_int/mod_xml_scgi

#../../libs/freetdm/mod_freetdm

FreeSWITCH

cd /opt/freeswitch/

./configure -C

make -j 4

make install 

make cd-sounds-install cd-moh-install

如果提示 freetdm相关异常的话,就rm /opt/freeswitch/libs/libfreetdm 类似的库

配置使用mariadb作为core数据库

在make install成功后,我们开始来配置使用的数据库

vim conf/autoload_configs/pre_load_modules.conf.xml 中加载

<load module="mod_mariadb"/>
vim /usr/local/freeswitch/conf/autoload_configs/switch.conf.xml

<param name="core-db-dsn" value="mariadb://Server=localhost;Database=freeswitch;Uid=root;Pwd=Nway123;" />
vim /usr/local/freeswitch/conf/autoload_configs/db.conf.xml

<param name="odbc-dsn" value="mariadb://Server=localhost;Database=freeswitch;Uid=root;Pwd=Nway123;"/>
cd /usr/local/freeswitch/conf/autoload_configs/

grep odbc-dsn 可以发现有以下的文件使用了odbc-dsn来连接数据库

./lcr.conf.xml:   <param name="odbc-dsn" value="freeswitch-mysql:freeswitch:Fr33Sw1tch"/>
./lcr.conf.xml:<!--   <param name="odbc-dsn" value="freeswitch-pgsql:freeswitch:Fr33Sw1tch"/> -->
./directory.conf.xml:     <!--<param name="odbc-dsn" value="dsn:user:pass"/>-->
./voicemail.conf.xml:     <!--<param name="odbc-dsn" value="dsn:user:pass"/>-->
./callcenter.conf.xml:   <!--<param name="odbc-dsn" value="dsn:user:pass"/>-->
./db.conf.xml:   <param name="odbc-dsn" value="mariadb://Server=localhost;Database=freeswitch;Uid=root;Pwd=Nway123;"/>
./cidlookup.conf.xml:   <param name="odbc-dsn" value="phone:phone:phone"/>
./nibblebill.conf.xml:   <param name="odbc-dsn" value="bandwidth.com"/>

这些的话就按需来吧

编译verto

apt-get update
apt-get -y install apache2 curl
curl -sL https://deb.nodesource.com/setup_11.x | bash -
apt-get update
apt-get -y install nodejs

cd /opt/freeswitch/html5/verto/verto_communicator
npm install -g grunt grunt-cli bower
npm install
bower --allow-root install
grunt build


mkdir -p /var/www/html/vc
cp -r /usr/src/freeswitch/html5/verto/verto_communicator/dist/* /var/www/html/vc/


sed -i 's/1234/12345/' /var/www/html/vc/config.json


a2enmod ssl
a2ensite default-ssl.conf
systemctl restart apache2
# if using self-signed cert
# navigate to port https://[IP]:8082 accept cert first
# then navigate to site https://[IP]/vc
启动FreeSWITCH
ln -s /usr/local/freeswitch/bin/freeswitch /usr/bin
freeswitch #直接启动
#能启动的话,通过 ... 退出整个freeswitch
freeswitch -nc #通过后台启动

Recent Articles

blog-post

限时免费实时质检、免费座席助手中间件

 注意,本次应用的能力为半实时,即不是每个语音包流都要送往识别,而是VAD后才送,识别后通过ESL发送消息后进行处理,用于座席辅助或半实时质检均可。部署方式为:云主机、物理机、测试型的内部虚拟机均可。识别特性:座席助手,或当检测到有异常,实 …