安装
其实就是先下载源码(freeswitch-1.6.20.tar.xz)然后解压,进入解压目录以后先./configure
再make && make install
。这个过程会遇到一些坑:
FreeSWITCH 安装配置的 各种坑, 填坑
freeswitch 安装和问题解决
普遍遇到的最多问题是类似“You must install xxx to build xxx”这种问题,直接百度都有答案。
(友情提示:我是centos7的系统,一般来说绝大多数的依赖包都在yum源里,可以直接yum install的方式安装,只不过yum源的名字可能有些差别,例如报错让你安装libmpg123-dev,只需yum install mpg123-devel
;报错让你安装libmp3lame-dev,只需yum install lame-devel
;报错说缺少libshout3-dev,只需yum install libshout-devel
等)
这里单独说一下opus的安装,安装fs的时候可能会报错:“You must install libopus-dev to build mod_opus”,解决方法是手动安装opus-devel和opus,例如我是通过rpm安装的:先下载opus-devel和opus的rpm包,然后执行rpm -ivh opus-devel-1.1.1-2.el7.x86_64.rpm
和rpm -ivh opus-1.1.1-2.el7.x86_64.rpm
。安装完opus和opus-devel后,重新./configure
并执行make clean
,否则可能会有问题,这一点在这里有讲到。很有可能在手动安装opus的时候系统会提示已安装过opus发生冲突,这时候执行yum remove opus
卸载掉原来的opus即可。关于opus这个模块,网上很多文章给出解决方案是修改Makefile文件绕过这个模块,但是本人并不推荐,因为fs的一些功能是依赖opus的(例如webrtc)。
关于声音文件安装。如果服务器能连外网,就很方便了,在源代码目录中执行:
make sounds-install
make moh-install
如果你的服务器不能连外网的话,可能还要手动下载声音文件并解压,然后放在/usr/local/freeswitch/sounds路径下。本人下载的是这两个(建议下载默认的8Khz语音文件):
http://files.freeswitch.org/releases/sounds/freeswitch-sounds-music-xxxx-1.0.52.tar.gz
http://files.freeswitch.org/releases/sounds/freeswitch-sounds-en-us-callie-xxxx-1.0.52.tar.gz
配置
一般在安装好fs后有以下几个和fs有关的配置:
- 数据库。部门里常见架构是本地mysql-connector+远端db,因此要安装一下mysql-connector:
rpm -ivh mysql-connector-odbc-5.3.4-1.el6.x86_64.rpm
- fs的数据源配置:/etc/odbc.ini
这里的设置在switch.conf.xml、odbc_cdr.con.xml等地方都会用到 - fs自动加载模块配置:/freeswitch/conf/autoload_configs/modules.conf.xml
这里要注意,如果要新增某个模块,改了这个xml文件后,还要进入fs的安装目录重新./configure
+make && make install
才能生效。 - fs全局变量:/freeswitch/conf/vars.xml
一般也就default_password需要改一下 - fs话单配置:/freeswitch/conf/autoload_configs/odbc_cdr.conf.xml
<configuration name="odbc_cdr.conf" description="ODBC CDR Configuration">
<settings>
<!-- <param name="odbc-dsn" value="database:username:password"/> -->
<param name="odbc-dsn" value="odbc://fsbackup::"/>
<!-- global value can be "a-leg", "b-leg", "both" (default is "both") -->
<param name="log-leg" value="both"/>
<!-- value can be "always", "never", "on-db-fail" -->
<param name="write-csv" value="on-db-fail"/>
<!-- location to store csv copy of CDR -->
<param name="csv-path" value="/usr/local/freeswitch/log/odbc_cdr"/>
<!-- if "csv-path-on-fail" is set, failed INSERTs will be placed here as CSV files otherwise they will be placed in "csv-path" -->
<param name="csv-path-on-fail" value="/usr/local/freeswitch/log/odbc_cdr/failed"/>
<!-- dump SQL statement after leg ends -->
<param name="debug-sql" value="true"/>
</settings>
<tables>
<!-- only a-legs will be inserted into this table -->
<table name="cdr2">
<field name="custom_id" chan-var-name="custom_id"/>
<field name="account_code" chan-var-name="accountcode"/>
<field name="record_file" chan-var-name="record_file"/>
<field name="username" chan-var-name="username"/>
<field name="caller_id_number" chan-var-name="caller_id_number"/>
<field name="destination_number" chan-var-name="destination_number"/>
<field name="uuid" chan-var-name="uuid"/>
<field name="bleg_uuid" chan-var-name="bleg_uuid"/>
<field name="ip_internal" chan-var-name="sip_via_host"/>
<field name="local_server" chan-var-name="local_ip_v4"/>
<field name="sip_to_host" chan-var-name="sip_to_host"/>
<field name="start_stamp" chan-var-name="start_stamp"/>
<field name="answer_stamp" chan-var-name="answer_stamp"/>
<field name="end_stamp" chan-var-name="end_stamp"/>
<field name="duration" chan-var-name="duration"/>
<field name="billsec" chan-var-name="billsec"/>
<field name="hangup_cause" chan-var-name="hangup_cause"/>
<field name="sip_hangup_disposition" chan-var-name="sip_hangup_disposition"/>
<field name="sip_endpoint_disposition" chan-var-name="endpoint_disposition"/>
<field name="direction" chan-var-name="direction"/>
</table>
</tables>
</configuration>