CentOS7-FreeSWITCH安装
说明
- CentOS7下FreeSWITCH安装
- 安装环境:CentOS7_x64
- 执行安装用户:root
操作步骤
关闭防火墙(如果有防火墙策略可以不用关闭,比如bt面板)
- 理论上防火墙只影响后期连接,不影响安装过程
- 本案例没有关闭
//临时关闭 $ systemctl stop firewalld //禁止开机启动 $ systemctl disable firewalld
安装依赖
$ yum install -y http://files.freeswitch.org/freeswitch-release-1-6.noarch.rpm epel-release $ yum install -y git alsa-lib-devel autoconf automake bison broadvoice-devel bzip2 curl-devel libdb4-devel e2fsprogs-devel erlang 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 python-devel python-devel soundtouch-devel speex-devel sqlite-devel unbound-devel unixODBC-devel wget which yasm zlib-devel libshout-devel libmpg123-devel lame-devel
安装ODBC
- 本案例仅仅执行了
install
,没有进行配置,后期配置可以参照下边的配置文件
$ yum install unixODBC-devel $ yum install mysql-connector-odbc
配置文件
/etc/odbcinst.ini
# Example driver definitions # Driver from the postgresql-odbc package # Setup from the unixODBC package [PostgreSQL] Description = ODBC for PostgreSQL Driver = /usr/lib/psqlodbcw.so Setup = /usr/lib/libodbcpsqlS.so Driver64 = /usr/lib64/psqlodbcw.so Setup64 = /usr/lib64/libodbcpsqlS.so FileUsage = 1 # Driver from the mysql-connector-odbc package # Setup from the unixODBC package [MySQL] Description = ODBC for MySQL Driver = /usr/lib/libmyodbc5.so Setup = /usr/lib/libodbcmyS.so Driver64 = /usr/lib64/libmyodbc5.so Setup64 = /usr/lib64/libodbcmyS.so FileUsage = 1
配置文件
/etc/odbc.ini
[freeswitch] Description=MySQL realtime database Driver=/usr/lib64/libmyodbc5.so SERVER =数据库地址 PORT =3306 DATABASE = freeswitch OPTION =67108864 CHARSET = UTF8 USER = 数据库账号 PASSWORD = 数据库密码 Threading = 0
测试数据库连接
$ isql -v freeswitch
- 本案例仅仅执行了
编译freeswitch 1.8.5
- 本案例没有直接在服务器上下载,因为服务器配置原因,直接wget慢到没朋友!我使用本地下载然后手动传上去进行解压编译安装
$ wget http://files.freeswitch.org/freeswitch-releases/freeswitch-1.8.5.tar.bz2 $ tar jxvf freeswitch-1.8.5.tar.bz2 $ cd freeswitch-1.8.5 $ ./configure -C --enable-core-odbc-support #如果不想使用mysql管理,只需要执行./configure即可 $ make $ make install
make中出现的错误:
making all mod_signalwire make[4]: Entering directory `/root/freeswitch/freeswitch-1.8.5/src/mod/applications/mod_signalwire' Makefile:916: *** You must install libks to build mod_signalwire. Stop. make[4]: Leaving directory `/root/freeswitch/freeswitch-1.8.5/src/mod/applications/mod_signalwire' make[3]: *** [mod_signalwire-all] Error 1
- 本案例实测:根据下边操作步骤,安装完
cmake
、libks
、signalwire-c
以上错误依旧存在!!! - 另外一种建议:最简单就是在
modules.conf
里面取消#applications/mod_signalwire
- 两种方法请自行斟酌使用!
根据报错可以看出需要安装需要安装 libks 和 signalwire-c,安装libks前需要先安装cmake。
$ yum install libatomic.x86_64 #libks还会提示少libatomic,有的不会提示,为了保证顺利安装,建议yum安装一下 $ cd ~/freeswitch $ wget https://cmake.org/files/v3.13/cmake-3.13.3.tar.gz $ tar -zxvf cmake-3.13.3.tar.gz $ cd cmake-3.13.3 $ ./bootstrap $ gmake $ make install
安装 libks
$ cd ~/freeswitch $ git clone https://github.com/signalwire/libks.git $ cd libks $ cmake . $ make $ make install $ # cp /usr/lib/pkgconfig/libks.pc /usr/lib64/pkgconfig/ # 实测x64环境不用此步
安装signalwire-c
$ cd ~/freeswitch $ git clone https://github.com/signalwire/signalwire-c.git $ cd signalwire-c/ $ cmake . $ make $ make install $ # cp /usr/local/lib/pkgconfig/*.pc /usr/lib64/pkgconfig/ # 实测x64环境不用此步 $ cp -f /usr/local/lib/* /usr/lib64/
- 重新编译安装
freeswitch
- 本案例实测:根据下边操作步骤,安装完
配置全局执行
$ ln -sf /usr/local/freeswitch/bin/freeswitch /usr/local/bin/ $ ln -sf /usr/local/freeswitch/bin/fs_cli /usr/local/bin/
安装声音文件
$ make cd-sounds-install $ make cd-moh-install
简单安全配置
$ cd ~/freeswitch/freeswitch-1.8.5/ $ make samples $ cd /usr/local/freeswitch/conf $ vi vars.xml # 修改默认密码(可选) <X-PRE-PROCESS cmd="set" data="default_password=1234"/> # SIP端口(可选) <X-PRE-PROCESS cmd="set" data="internal_sip_port=5060"/> <X-PRE-PROCESS cmd="set" data="internal_tls_port=5061"/> <X-PRE-PROCESS cmd="set" data="external_sip_port=5080"/> <X-PRE-PROCESS cmd="set" data="external_tls_port=5081"/> $ vi autoload_configs/event_socket.conf.xml # 修改Eventsocket端口(可选) # 修改后fs_cli访问FS命令行时,需要:fs_cli -P 7021 <param name="listen-port" value="8021"/> # 修改Eventsocket绑定ip,默认:value="::",默认配置fs_cli是无法连接的 <param name="listen-ip" value="0.0.0.0"/>
启动FS
# 前台启动 $ freeswitch # 关闭freeswitch $ shutdown # 后台启动 $ freeswitch -nc # 关闭后台freeswitch $ freeswitch -stop
启动ERR
1970-06-13 11:38:26.704643 [ERR] sofia.c:3228 Error Creating SIP UA for profile: external-ipv6 (sip:mod_sofia@[::1]:5080;transport=udp,tcp) ATTEMPT 2 (RETRY IN 5 SEC) 1970-06-13 11:38:26.704643 [ERR] sofia.c:3228 Error Creating SIP UA for profile: internal-ipv6 (sip:mod_sofia@[::1]:5060;transport=udp,tcp) ATTEMPT 2 (RETRY IN 5 SEC) 1970-06-13 11:38:31.704644 [ERR] sofia.c:3228 Error Creating SIP UA for profile: external-ipv6 (sip:mod_sofia@[::1]:5080;transport=udp,tcp) ATTEMPT 3 (RETRY IN 5 SEC) 1970-06-13 11:38:31.704644 [ERR] sofia.c:3238 Error Creating SIP UA for profile: external-ipv6 (sip:mod_sofia@[::1]:5080;transport=udp,tcp) The likely causes for this are: 1) Another application is already listening on the specified address. 2) The IP the profile is attempting to bind to is not local to this system. 1970-06-13 11:38:31.704644 [ERR] sofia.c:3228 Error Creating SIP UA for profile: internal-ipv6 (sip:mod_sofia@[::1]:5060;transport=udp,tcp) ATTEMPT 3 (RETRY IN 5 SEC) 1970-06-13 11:38:31.704644 [ERR] sofia.c:3238 Error Creating SIP UA for profile: internal-ipv6 (sip:mod_sofia@[::1]:5060;transport=udp,tcp) The likely causes for this are: 1) Another application is already listening on the specified address. 2) The IP the profile is attempting to bind to is not local to this system.
禁用ipv6
$ cd /usr/local/freeswitch/ $ mv conf/sip_profiles/internal-ipv6.xml conf/sip_profiles/internal-ipv6.xml.bak $ mv conf/sip_profiles/external-ipv6.xml conf/sip_profiles/external-ipv6.xml.bak
- 重启freeswitch
客户端连接
$ fs_cli $ # fs_cli -P 8021 # 指定端口 .=======================================================. | _____ ____ ____ _ ___ | | | ___/ ___| / ___| | |_ _| | | | |_ \___ \ | | | | | | | | | _| ___) | | |___| |___ | | | | |_| |____/ \____|_____|___| | | | .=======================================================. | Anthony Minessale II, Ken Rice, | | Michael Jerris, Travis Cross | | FreeSWITCH (http://www.freeswitch.org) | | Paypal Donations Appreciated: paypal@freeswitch.org | | Brought to you by ClueCon http://www.cluecon.com/ | .=======================================================. ......
连接错误:
[ERROR] fs_cli.c:1679 main() Error Connecting [] ......
- 关闭防火墙
查看客户端状态
# 查看状态: # 在 fs_cli 中输入 status freeswitch@iZ8vbgfs3t229wkod1pn> status UP 0 years, 0 days, 0 hours, 0 minutes, 19 seconds, 816 milliseconds, 207 microseconds FreeSWITCH (Version 1.8.5 64bit) is ready 0 session(s) since startup 0 session(s) - peak 0, last 5min 0 0 session(s) per Sec out of max 30, peak 0, last 5min 0 1000 session(s) max min idle cpu 0.00/99.87 Current Stack Size/Max 240K/8192K # 在 fs_cli 中输入 sofia status freeswitch@iZ8vbgfs3t229wkod1pn> sofia status Name Type Data State ================================================================================================= 192.168.1.100 alias internal ALIASED external profile sip:mod_sofia@192.168.1.100:5080 RUNNING (0) external::example.com gateway sip:joeuser@example.com NOREG internal profile sip:mod_sofia@192.168.1.100:5060 RUNNING (0) ================================================================================================= 2 profiles 1 alias