一、安装odbc
apt-get install unixodbc
如果需要用到编译的头文件之类的
apt-get install unixodbc-dev
二、安装mysql驱动
apt-get install libmyodbc
多数可能出现这个报错:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package libmyodbc is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package'libmyodbc' has no installation candidate
三、手动下载安装驱动
选择合适的版本和驱动
解压后,将库文件拷贝到合适的目录。
四、配置mysql驱动信息
文件:/etc/odbcinst.ini
[MySQL]
Description=ODBC forMySQL
Driver=/usr/lib/x86_64-linux-gnu/odbc/libmyodbc5a.so //步骤3拷贝的路径
Setup=/usr/lib/x86_64-linux-gnu/odbc/libmyodbc5S.so
FileUsage=1
五、配置需要访问的数据库信息
文件:/etc/odbc.ini
[freeswitch]
Driver= /usr/lib/x86_64-linux-gnu/odbc/libmyodbc5a.so3 SERVER =localhost
PORT= 3306DATABASE=freeswitch
OPTION= 67108864 //这个配置是支持多线程?对于freeswitch访问来说很重要!
USER =root
PASSWORD= password
六、测试驱动
isql -v freeswitch //先去数据库里创建一个表freeswitch
如果一切正常,能进入mysql后台。
反之,根据提示完善系统。
安装FreeSwitch
生成makefile
./configure --enable-core-odbc-support
编译 安装
make && make install (sudo make 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 +
+ +
+-------------------------------------------------+
View Code
默认安装目录:/usr/local/freeswitch/
FreeSWITCH使用mysql存储用户
二、创建数据库
#创建用户表
#创建用户表CREATE TABLE `user` (
`id`int(11) NOT NULLAUTO_INCREMENT,
`user` varchar(10) DEFAULT NULL,
`password`varchar(30) DEFAULT NULL,PRIMARY KEY(`id`),
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8;
#插入两个用户insert into user (user,password) values('8001','123456')insert into user (user,password) values('8002','123456')
三、将用户验证转接到lua脚本
1、将freeswitch/conf/autoload_configs/lua.conf.xml中的两行代码修改为如下所示
2、让lua脚本接管用户注册验证,这里调用的脚本是freeswitch/script/gen_dir_user_xml.lua内容如下,默认无该脚本,需自行创建
freeswitch.consoleLog("NOTICE","lua take the users...\n");local req_domain = params:getHeader("domain")local req_key = params:getHeader("key")local req_user = params:getHeader("user")local req_password = params:getHeader("pass")
freeswitch.consoleLog("NOTICE","start connect DB...\r\n");local dbh = freeswitch.Dbh("freeswitch","root","123456");assert(dbh:connected());
dbh:query("select password from user where user="..req_user,function(row)
freeswitch.consoleLog("NOTICE","DB select password="..string.format("%s\n",row.password))
req_password=string.format("%s",row.password)end);
dbh:release();
freeswitch.consoleLog("NOTICE","info:"..req_domain.."--"..req_key.."--"..req_user.."--"..req_password.."\n");if req_domain ~= nil and req_key ~= nil and req_user ~= nil thenXML_STRING=
[[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
value="{presence_id=${dialed_user}@${dialed_domain}}${sofia_contact(${dialed_user}@${dialed_domain})}"/>
]]
elseXML_STRING=
[[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
]]
endfreeswitch.consoleLog("NOTICE", "debug from gen_dir_user_xml.lua, generated XML:\n" .. XML_STRING .. "\n");
3、修改freeswitch/conf/directory/default.xml中的一部分内容,使得通过xml验证用户的功能失效,这样lua才能真正接管用户注册,删除的内容如下:
四、测试
使用SIP软电话(zoiper、eyeBeam等)来测试8001、或8002是否能正常登陆,可登陆即为配置成功
运行freeswitch
freeswitch -c -nonat