本次安装环境是centos 7, 源码目录是 /usr/local/src/freeswitch 下载源码(1.6.20是目前1.6的最新版) cd /usr/local/src git clone -b v1.6.20 https://freeswitch.org/stash/scm/fs/freeswitch.git freeswitch 配置编译安装的基础环境 yum install -y git alsa-lib-devel autoconf automake bison broadvoice-devel bzip2 curl-devel db-devel e2fsprogs-devel flite-devel g722_1-devel gcc-c++ gdbm-devel gnutls-devel ilbc2-devel ldns-devel libcodec2-devel libcurl-devel libedit-devel libidn-devel libjpeg-devel libmemcached-devel libogg-devel libsilk-devel libsndfile-devel libtheora-devel libtiff-devel libtool libuuid-devel libvorbis-devel libxml2-devel lua-devel lzo-devel mongo-c-driver-devel ncurses-devel net-snmp-devel openssl-devel opus-devel pcre-devel perl perl-ExtUtils-Embed pkgconfig portaudio-devel postgresql-devel python26-devel python-devel soundtouch-devel speex-devel sqlite-devel unbound-devel unixODBC-devel wget which yasm zlib-devel 2.1 要是需要安装mysql数据库支持,需要多装以下的依赖
yum install unixODBC -devel yum install mysql-connector-odbc 运行 ./rebootstrap.sh 初始化环境变量 cd /usr/local/src/freeswitch ./rebootstrap.sh 运行 ./configure 配置编译环境 cd /usr/local/src/freeswitch ./configure --prefix=/usr/local/freeswitch_1_6_20 --disable-multilib > configure.consolelog.txt 如果需要连接mysql数据库需要用下面的参数
cd /usr/local/src/freeswitch ./configure --prefix=/usr/local/freeswitch_1_6_20 --disable-multilib -C --enable-core-odbc-support > configure.consolelog.txt 4.1 上面把配置过程导入到 configure.consolelog.txt中,方便后续编译出错时查找相关的提示信息。 4.2 上面配置了–prefix 指定freeswitch1.6.20编译安装到/usr/local/freeswitch_1_6_20目录下,如果不配置则默认是/usr/local/freeswitch,主要是后续安装新版本方便。 4.3 上面配置了–disable-multilib,因为我们不需要跨32位支持,避免因为跨平台编译导致一些意外的错误。 4.4 这个脚本在每次编译前都要执行一次,不管是全部源码编译还是mod插件编译,可以避免编译出现意外
执行 make 进行编译 cd /usr/local/src/freeswitch make 5.1make时会遇到一些小问题,基本解决思路是:
先看make的提示,是缺少什么依赖库 再查看刚才保存的configure.consolelog.txt,看看具体依赖的版本,因为FS编译时对具体的版本也是有要求的,不符合版本要求也不行 然后到https://centos.pkgs.org去查找相关的以来库的rpm文件 下载安装相关依赖库 重新执行 步骤4 运行 ./configure --prefix=/usr/local/freeswitch_1_6_20 --disable-multilib > configure.consolelog.txt 配置编译环境. 重新执行 make 以下是解决按照FS默认配置编译时,遇到的一些问题及解决方案
5.1.1 缺少yasm时的解决方案。
问题,执行make时,可能提示找不到yasm,导致make失败,解决方法如下:
#下载 wget http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/y/yasm-1.2.0-4.el7.x86_64.rpm #从RPM安装 rpm -Uvh yasm-1.2.0-4.el7.x86_64.rpm 5.1.2 1.6版本默认安装 mod_opus,该插件安装失败的解决方案
问题,查询configure.consolelog.txt,可以发现项目依赖opus 1.1版本
#查看系统支持的opus版本: yum list opus #可见系统只支持 1.0.2-6.el7 #因此先卸载 yum remove -y opus #重新安装 1.1版本 #先下载 opus 1.1 wget http://pkgrepo.linuxtech.net/el6/release/x86_64/libopus-1.1-1.el6.x86_64.rpm #安装 rpm -Uvh libopus-1.1-1.el6.x86_64.rpm #再下载opus-devel 1.1 wget http://pkgrepo.linuxtech.net/el6/release/x86_64/libopus-devel-1.1-1.el6.x86_64.rpm #安装 rpm -Uvh libopus-devel-1.1-1.el6.x86_64.rpm #重新执行 ./configure --prefix=/usr/local/freeswitch_1_6_20 --disable-multilib --with-lib-subdir=/usr/lib64 > configure.consolelog.txt #配置编译环境. checking for opus >= 1.1… yes #依赖检查通过 #重新 make 即可成功 5.2 make 成功后的效果
±--------- FreeSWITCH Build Complete ----------+
- FreeSWITCH has been successfully built. +
- Install by running: +
-
+
- make install +
-
+
- While you’re waiting, register for ClueCon! +
- https://www.cluecon.com +
-
+
±----------------------------------------------+ 执行 make install 进行安装 cd /usr/local/src/freeswitch make install install成功后的效果
±--------- FreeSWITCH install Complete ----------+
- FreeSWITCH has been successfully installed. +
-
+
- Install sounds: +
- (uhd-sounds includes hd-sounds, sounds) +
- (hd-sounds includes sounds) +
- ------------------------------------ +
- make cd-sounds-install +
- make cd-moh-install +
-
+
- make uhd-sounds-install +
- make uhd-moh-install +
-
+
- make hd-sounds-install +
- make hd-moh-install +
-
+
- make sounds-install +
- make moh-install +
-
+
- Install non english sounds: +
- replace XX with language +
- (ru : Russian) +
- (fr : French) +
- ------------------------------------ +
- make cd-sounds-XX-install +
- make uhd-sounds-XX-install +
- make hd-sounds-XX-install +
- make sounds-XX-install +
-
+
- Upgrade to latest: +
- ------------------------------------ +
- make current +
-
+
- Rebuild all: +
- ------------------------------------ +
- make sure +
-
+
- Install/Re-install default config: +
- ------------------------------------ +
- make samples +
-
+
-
+
- Additional resources: +
- ------------------------------------ +
- https://www.freeswitch.org +
- https://freeswitch.org/confluence +
- https://freeswitch.org/jira +
- http://lists.freeswitch.org +
-
+
- irc.freenode.net / #freeswitch +
-
+
- Register For ClueCon: +
- ------------------------------------ +
- https://www.cluecon.com +
-
+
±------------------------------------------------+ 6.1 安装语音包
make sounds-install make moh-install 简单安全配置 #FS默认没有配置,需要安装配置 cd /usr/local/src/freeswitch make samples cd /usr/local/freeswitch_1_6_20/etc/freeswitch 7.1 修改默认密码
#默认是1234 vi vars.xml #修改 #为 7.2 修改默认端口
7.2.1 Eventsocket端口
这个不用改也行
vi autoload_configs/event_socket.conf.xml
修改 为
修改后 fs_cli 访问 FS命令行时,需要
fs_cli -P 7021
7.2.2 SIP端口
vi vars.xml
修改
为
修改
为
运行测试 8.1 启动FS
8.1.1 建立 FS 命令行的映射
建立 FS 命令行的映射,方便后续随时启动
ln -sf /usr/local/freeswitch_1_6_20/bin/freeswitch /usr/bin/ ln -sf /usr/local/freeswitch_1_6_20/bin/fs_cli /usr/bin/ 8.1.2 启动 FS
#前台启动 freeswitch
#后台启动 freeswitch -nc 8.1.3 连接命令行
fs_cli -P 7021 8.2 sip软电话接入测试
8.2.1 安装sip话机 百度 zoiper3下载 安装
8.2.2 配置sip话机 user: 1002 password: 7654321 Domain: 192.168.43.110:3060 其他默认
8.2.3 拨打测试 拨打 5000 如果一切OK,就可以接通到FS的IVR测试菜单
编译插件支持mp3播放
切换到 FS的源代码目录
cd /usr/local/src/freeswitch vi modules.conf
取消 formats/mod_shout 前的注释#
make mod_shout-install
编译安装成功后
cd /usr/local/freeswitch_1_6_20 vi etc/freeswitch/autoload_configs/modules.conf.xml
取消 的注释,以后FS会自动加载shout模块
#从命令行加载shout模块 load mod_shout 9.1 解决 *** You must install libshout3-dev to build mod_shout。 停止。 问题
检查 configure.consolelog.txt
vi configure.consolelog.txt
发现 依赖 checking for shout >= 2.2.2… no
到 https://centos.pkgs.org 查一下
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/libshout-2.2.2-11.el7.x86_64.rpm wget http://mirror.centos.org/centos/7/os/x86_64/Packages/libshout-devel-2.2.2-11.el7.x86_64.rpm rpm -Uvh libshout-2.2.2-11.el7.x86_64.rpm rpm -Uvh libshout-devel-2.2.2-11.el7.x86_64.rpm
重新配置 编译安装环境
./configure --prefix=/usr/local/freeswitch_1_6_20 --disable-multilib --with-lib-subdir=/usr/lib64 > configure.consolelog.txt
查看 配置结果: checking for shout >= 2.2.2… yes
make mod_shout-install 就可以成功了
9.2 解决 *** You must install libmpg123-dev to build mod_shout。 停止。 问题
检查 configure.consolelog.txt
vi configure.consolelog.txt
发现 依赖 checking for libmpg123 >= 1.16.0… no
到 https://centos.pkgs.org 查一下
wget http://ftp.altlinux.org/pub/distributions/ALTLinux/Sisyphus/x86_64/RPMS.classic//libmpg123-1.25.10-alt1.x86_64.rpm wget http://ftp.altlinux.org/pub/distributions/ALTLinux/Sisyphus/x86_64/RPMS.classic//libmpg123-devel-1.25.10-alt1.x86_64.rpm rpm -Uvh libmpg123-1.25.10-alt1.x86_64.rpm rpm -Uvh libmpg123-devel-1.25.10-alt1.x86_64.rpm
重新配置 编译安装环境
./configure --prefix=/usr/local/freeswitch_1_6_20 --disable-multilib --with-lib-subdir=/usr/lib64 > configure.consolelog.txt
查看 配置结果: checking for libmpg123 >= 1.16.0… yes
make mod_shout-install 就可以成功了
9.3 解决 *** You must install libmp3lame-dev to build mod_shout。 停止。问题
检查 configure.consolelog.txt
vi configure.consolelog.txt
发现 依赖 checking for lame_init in -lmp3lame… no
wget http://pkgrepo.linuxtech.net/el6/release/x86_64/libmp3lame-3.98.4-4.el6.x86_64.rpm wget http://pkgrepo.linuxtech.net/el6/release/x86_64/libmp3lame-devel-3.98.4-4.el6.x86_64.rpm rpm -Uvh libmp3lame-3.98.4-4.el6.x86_64.rpm rpm -Uvh libmp3lame-devel-3.98.4-4.el6.x86_64.rpm
重新配置 编译安装环境
./configure --prefix=/usr/local/freeswitch_1_6_20 --disable-multilib --with-lib-subdir=/usr/lib64 > configure.consolelog.txt
查看 配置结果: checking for lame_init in -lmp3lame… yes
make mod_shout-install 就可以成功了
编译插件支持英文TTS
切换到 FS的源代码目录
cd /usr/local/src/freeswitch vi modules.conf
取消 formats/asr_tts/mod_flite 前的注释#
make mod_flite-install
编译安装成功后
cd /usr/local/freeswitch_1_6_20 vi etc/freeswitch/autoload_configs/modules.conf.xml
取消 的注释
以后FS会自动加载flite模块
#从命令行加载flite模块 load mod_flite 10.1 解决 *** You must install libflite-dev to build mod_flite。 问题
检查 configure.consolelog.txt 发现 依赖 checking for flite >= 2.0.0… no
flite = 1.3-22.el7 被 (已安裝) flite-devel-1.3-22.el7.x86_64 需要
yum remove -y flite #卸载 git clone https://github.com/festvox/flite.git flite-2.1.0 cd flite-2.1.0 ./configure --prefix=/usr/lib64/flite2.1 --enable-shared #注意一定要加上enable-shared,否则编译不出来动态链接库,后面编译还是会失败. 2.0.0版还要 --enable-fPIC
make && make install ln -s /usr/lib64/flite2.1/lib/* /usr/lib64/ vi /usr/lib64/pkgconfig/flite.pc 粘贴
prefix=/usr/lib64/flite2.1 exec_prefix=
p
r
e
f
i
x
l
i
b
d
i
r
=
{prefix} libdir=
prefixlibdir={exec_prefix}/lib includedir=
p
r
e
f
i
x
/
i
n
c
l
u
d
e
N
a
m
e
:
f
l
i
t
e
D
e
s
c
r
i
p
t
i
o
n
:
a
t
e
x
t
t
o
s
p
e
e
c
h
l
i
b
r
a
r
y
R
e
q
u
i
r
e
s
:
V
e
r
s
i
o
n
:
2.1.0
L
i
b
s
:
?
L
{prefix}/include Name: flite Description: a text to speech library Requires: Version: 2.1.0 Libs: -L
prefix/includeName:fliteDescription:atexttospeechlibraryRequires:Version:2.1.0Libs:?L{libdir} -lflite -lflite_cmu_grapheme_lang -lflite_cmu_grapheme_lex -lflite_cmu_indic_lang -lflite_cmu_indic_lex -lflite_cmulex -lflite_cmu_time_awb -lflite_cmu_us_awb -lflite_cmu_us_kal16 -lflite_cmu_us_kal -lflite_cmu_us_rms -lflite_cmu_us_slt -lflite_usenglish Libs.private: -lm Cflags: -I${includedir}/flite/
重新配置 编译安装环境
./configure --prefix=/usr/local/freeswitch_1_6_20 --disable-multilib --with-lib-subdir=/usr/lib64 > configure.consolelog.txt
checking for flite >= 2.0.0… yes
make mod_flite-install 就可以成功了
配置外呼
通过ODBC支持MySQL数据库的具体过程
11.1 安装unixODBC支持
yum install unixODBC unixODBC-devel libtool-ltdl libtool-ltdl-devel 11.2 下载安装MySQL ODBC驱动
wget https://dev.mysql.com/get/Downloads/Connector-ODBC/8.0/mysql-connector-odbc-8.0.13-1.el7.x86_64.rpm rpm -ivh mysql-connector-odbc-8.0.13-1.el7.x86_64.rpm 11.3 配置ODBC连接的DSN
vi /etc/odbcinst.ini 修改其中的 [MySQL ODBC 8.0 UNICODE Driver] 为 [MySQLTDS] 不改也没事,主要是好用好记
11.4 新建freeswitch的连接串
vi /etc/odbc.ini 内容如下:
[freeswitch] DRIVER = MySQLTDS SERVER = localhost Port = 3306 DATABASE = freeswitch OPTION = 67108864 USER = username PASSWORD = password 11.5 创建freeswitch数据库
mysql -uroot -p –用root密码登录 –执行创建库命令 CREATE DATABASE IF NOT EXISTS freeswitch DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
show create database freeswitch; ±-----------±--------------------------------------------------------------------+ | Database | Create Database | ±-----------±--------------------------------------------------------------------+ | freeswitch | CREATE DATABASE freeswitch /*!40100 DEFAULT CHARACTER SET utf8 */ | ±-----------±--------------------------------------------------------------------+ 1 row in set (0.00 sec)
11.6 测试连接 运行下面的命令,结果如下就成功了。
isql -v freeswitch ±--------------------------------------+ | Connected! | | | | sql-statement | | help [tablename] | | quit | | | ±--------------------------------------+ 11.7 重新编译freeswitch,打开ODBC支持
./configure --prefix=/usr/local/freeswitch_1_6_20 --disable-multilib -C --enable-core-odbc-support > configure.consolelog.txt make make install 11.8 配置freeswitch的数据库DSN
find . -name “*.xml” | xargs grep dsn ./etc/freeswitch/autoload_configs/cidlookup.conf.xml: ./etc/freeswitch/autoload_configs/directory.conf.xml:
./etc/freeswitch/autoload_configs/easyroute.conf.xml: ./etc/freeswitch/autoload_configs/lcr.conf.xml: ./etc/freeswitch/autoload_configs/lcr.conf.xml:
./etc/freeswitch/autoload_configs/nibblebill.conf.xml: ./etc/freeswitch/autoload_configs/voicemail.conf.xml:
./etc/freeswitch/autoload_configs/callcenter.conf.xml: ./etc/freeswitch/autoload_configs/db.conf.xml: ./etc/freeswitch/autoload_configs/switch.conf.xml:
./etc/freeswitch/autoload_configs/switch.conf.xml: ./etc/freeswitch/jingle_profiles/server.xml:
./etc/freeswitch/jingle_profiles/server.xml:
./etc/freeswitch/sip_profiles/internal-ipv6.xml:
./etc/freeswitch/sip_profiles/internal-ipv6.xml:
./etc/freeswitch/sip_profiles/internal.xml:
./etc/freeswitch/sip_profiles/internal.xml:
./etc/freeswitch/sip_profiles/internal.xml:
./etc/freeswitch/skinny_profiles/internal.xml: 把上面找到的文件中的dsn:user:pass 改成 freeswitch:username:password
11.9 启动freeswitch, 系统会自动创建表,至此,freeswitch支持mysql完成。
11.10 bug记录 上述操作后,执行channels的默认建表脚本,会报错。因为没有深究为什么需要varchar(1024)的字段,为了不影响后续功能,暂时把所有的VARCHAR(1024)改成TEXT类型,手动创建后,再运行freeswitch后解决。
–默认建表脚本 CREATE TABLE channels ( uuid VARCHAR(256), direction VARCHAR(32), created VARCHAR(128), created_epoch INTEGER, name VARCHAR(1024), state VARCHAR(64), cid_name VARCHAR(1024), cid_num VARCHAR(256), ip_addr VARCHAR(256), dest VARCHAR(1024), application VARCHAR(128), application_data VARCHAR(4096), dialplan VARCHAR(128), context VARCHAR(128), read_codec VARCHAR(128), read_rate VARCHAR(32), read_bit_rate VARCHAR(32), write_codec VARCHAR(128), write_rate VARCHAR(32), write_bit_rate VARCHAR(32), secure VARCHAR(64), hostname VARCHAR(256), presence_id VARCHAR(4096), presence_data VARCHAR(4096), accountcode VARCHAR(256), callstate VARCHAR(64), callee_name VARCHAR(1024), callee_num VARCHAR(256), callee_direction VARCHAR(5), call_uuid VARCHAR(256), sent_callee_name VARCHAR(1024), sent_callee_num VARCHAR(256), initial_cid_name VARCHAR(1024), initial_cid_num VARCHAR(256), initial_ip_addr VARCHAR(256), initial_dest VARCHAR(1024), initial_dialplan VARCHAR(128), initial_context VARCHAR(128) );
|