本文已参与「新人创作礼」活动,一起开启掘金创作之路。
Centos7 下安装freeswitch 1.9 +x264+odbc mysql
前期准备
安装lua5.2及以上版本
安装mod_av支持的lib
安装odbc
安装php--为freeswitch后期扩展开发预备
编译freeswitch 1.9
configure中间出现的错误:
make中间出现的错误:
在fs上开启rport功能
设置rtp自动调整功能
防火墙和NAT设置
加载mod_av
连接MySQL数据库
支持视频通话
前期准备
yum install net-tools
关闭防火墙
//临时关闭
systemctl stop firewalld
//禁止开机启动
systemctl disable firewalld
setenforce 0
1
2
3
4
5
借用1.6版本的部分依赖库,懒得区分什么是刚需,copy一下直接贴过来了
yum install -y files.freeswitch.org/freeswitch-… epel-release
yum install -y git gcc-c++ autoconf automake libtool wget python ncurses-devel zlib-devel libjpeg-devel openssl-devel e2fsprogs-devel sqlite-devel libcurl-devel pcre-devel speex-devel ldns-devel libedit-devel libxml2-devel libyuv-devel opus-devel libvpx-devel libvpx2* libdb4* libidn-devel unbound-devel libuuid-devel lua-devel libsndfile-devel yasm-devel
1
2
3
安装lua5.2及以上版本
1.CentOS7默认已经安装了5.1.4 然并卵,freeswitch1.4以后就需要5.2以上lua来支持了,不然后期调试mysql lua会带来恶心的感觉。
①查看当前lua版本号:
lua -v
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
1
2
3
②查看lua和luac的位置:
which lua luac
/usr/bin/lua
/usr/bin/luac
1
2
3
4
2.编译Lua5.3版本
①下载lua-5.3.5.tar.gz
②make linux
出现错误:lua.c:80:31: fatal error: readline/readline.h: No such file or directory
表示需要安装依赖库:yum install readline-devel
③make install
cd src && mkdir -p /usr/local/bin /usr/local/include /usr/local/lib /usr/local/man/man1 /usr/local/share/lua/5.3 /usr/local/lib/lua/5.3
cd src && install -p -m 0755 lua luac /usr/local/bin
cd src && install -p -m 0644 lua.h luaconf.h lualib.h lauxlib.h lua.hpp /usr/local/include
cd src && install -p -m 0644 liblua.a /usr/local/lib
cd doc && install -p -m 0644 lua.1 luac.1 /usr/local/man/man1
1
2
3
4
5
可以看到,lua和luac被安装到了/usr/local/bin中
④lua -v查看版本,发现还是旧的版本,那我们就将/usr/bin中的lua和luac删除,然后将/usr/local/bin中的lua和luac创建一个ln到/usr/bin中即可
cd /usr/bin
rm -rf lua luac
ln -s /usr/local/bin/lua /usr/bin/lua
ln -s /usr/local/bin/luac /usr/bin/luac
lua -v
Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio
1
2
3
4
5
6
7
8
9
10
11
安装mod_av支持的lib
要支持h264视频通话,所以需要单独安装
mod_av 依赖libav, libav需要 x264 lib才能支持h264。
先下载源码
libav.org/
download.videolan.org/pub/videola…
cd /usr/loca/src
git clone git.videolan.org/git/x264.gi…
wget libav.org/releases/li…
tar -zxvf libav-12.3.tar.gz
1
2
3
4
因为编译x264会提示
Found no assembler
Minimum version is nasm-2.13
所以需要手动安装 nasm 因为centos7自带的版本不够,
下载一个顺眼的版本 来三部曲安装吧
www.nasm.us/pub/nasm/re…
wget www.nasm.us/pub/nasm/re…
tar -zxvf nasm-2.14.tar.gz
cd nasm-2.14
./configure
make
make install
cd ../x264
./configure --enable-shared --enable-static --disable-opencl
make
make install
cp /usr/local/lib/pkgconfig/x2* /usr/lib64/pkgconfig #否则libav在configure时会提示ERROR:x264 not found
1
2
3
4
5
6
7
8
9
10
11
libav编译时出错:
libavcodec/libx264.c: In function ‘X264_frame’:
libavcodec/libx264.c:246:9: error: ‘x264_bit_depth’ undeclared (first use in this function)
if (x264_bit_depth > 8)
^
libavcodec/libx264.c:246:9: note: each undeclared identifier is reported only once for each function it appears in
libavcodec/libx264.c: In function ‘X264_init_static’:
libavcodec/libx264.c:707:9: error: ‘x264_bit_depth’ undeclared (first use in this function)
if (x264_bit_depth == 8)
看了一圈没几个正经解决方案,参考x264对ffmpeg的补丁解决 git.videolan.org/?p=ffmpeg.g…
static av_cold void X264_init_static(AVCodec *codec)
{
- if (x264_bit_depth == 8)
- if (X264_BIT_DEPTH == 8)
codec->pix_fmts = pix_fmts_8bit;
- else if (x264_bit_depth == 9)
- else if (X264_BIT_DEPTH == 9)
codec->pix_fmts = pix_fmts_9bit;
- else if (x264_bit_depth == 10)
- else if (X264_BIT_DEPTH == 10)
codec->pix_fmts = pix_fmts_10bit;
}
1
2
3
4
5
6
7
8
9
10
11
12
cd ../libav-12.3
./configure --enable-shared --enable-libx264 --enable-gpl
make
make install
cp /usr/local/lib/pkgconfig/ .pc /usr/lib64/pkgconfig/
cp -f /usr/local/lib/ /usr/lib64/
1
2
3
4
5
6
7
增加mod_nuimrcp模块
编辑 vim ./build/modules.conf.in
修改 #applications/mod_av为applications/mod_av
修改 #asr_tts/mod_unimrcp 为 asr_tts/mod_unimrcp
安装odbc
因为后面会涉及到odbc的安装,所以先安装odbc
yum install -y unixODBC unixODBC-devel mysql-connector-odbc
1
安装完成后编辑/etc/odbcinst.ini
Example driver definitions
Driver from the postgresql-odbc package
Setup from the unixODBC package
1、安装unixodbc
brew install unixodbc
安装目录为/usr/local/Cellar/unixodbc/2.3.7
安装完成会在/usr/local/etc目录下生成odbc.ini和odbcinst.ini文件
2、下载安装mysql odbc connector
安装目录 /usr/local/mysql-connector-odbc-5.3.12-macos10.14-x86-64bit
cd /usr/local/mysql-connector-odbc-5.3.12-macos10.14-x86-64bit/bin
执行命令
./myodbc-installer -d -a -n "MySQL ODBC 5.3 ANSI Driver" -t "DRIVER=/usr/local/mysql-connector-odbc-5.3.12-macos10.14-x86-64bit/lib/libmyodbc5a.so”
myodbc-installer -a -s -n "freeswitch" -t "DRIVER=MySQL ODBC 5.3 ANSI Driver;SERVER=localhost;USER=free;PASSWORD=123456;OPTION=67108864”
会生成/Library/ODBC/下的两个文件
cp /Library/ODBC/odbc.ini ~/Library/ODBC
cp /Library/ODBC/odbcinst.ini ~/Library/ODBC
cp /Library/ODBC/odbc.ini /usr/local/etc/
cp /Library/ODBC/odbcinst.ini/usr/local/etc/
3、验证odbc 安装成功
isql -v freeswitch
\
4、freeswitch 支持odbc
cd /usr/local/src/freeswitch/src
sudo ./configure —enable-core-odbc-support=true
sudo make && make install
core数据库支持mysql odbc
修改 conf/autoload_configs/switch.conf.xml
sip支持mysql odbc
修改conf/sip_profiles/internal.xml
5、运行freeswitch
cd /usr/local/freeswitch/db/
rm *
运行:freeswitch -c nonat
\