Centos7 下安装freeswitch 1.9 +x264+odbc mysql
前期准备
yum install net-tools
关闭防火墙
//临时关闭
systemctl stop firewalld
//禁止开机启动
systemctl disable firewalld
setenforce 0
借用1.6版本的部分依赖库,懒得区分什么是刚需,copy一下直接贴过来了
yum install -y http://files.freeswitch.org/freeswitch-release-1-6.noarch.rpm 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
安装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
②查看lua和luac的位置:
which lua luac
/usr/bin/lua
/usr/bin/luac
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
可以看到,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
安装mod_av支持的lib
要支持h264视频通话,所以需要单独安装
mod_av 依赖libav, libav需要 x264 lib才能支持h264。
先下载源码
https://libav.org/
https://download.videolan.org/pub/videolan/x264/snapshots/
cd /usr/loca/src
git clone https://git.videolan.org/git/x264.git
wget https://libav.org/releases/libav-12.3.tar.gz
tar -zxvf libav-12.3.tar.gz
因为编译x264会提示
Found no assembler
Minimum version is nasm-2.13
所以需要手动安装 nasm 因为centos7自带的版本不够,
下载一个顺眼的版本 来三部曲安装吧
https://www.nasm.us/pub/nasm/releasebuilds/
wget https://www.nasm.us/pub/nasm/releasebuilds/2.14/nasm-2.14.tar.gz
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
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的补丁解决 http://git.videolan.org/?p=ffmpeg.git;a=patch;h=2a111c99a60fdf4fe5eea2b073901630190c6c93
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;
}
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/
增加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
安装完成后编辑/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/lib64/libmyodbc5.so
Setup = /usr/lib64/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测试是否能够连通
安装php–为freeswitch后期扩展开发预备
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
//查看
yum search php72w
//安装php以及扩展
yum install php72w php72w-fpm php72w-cli php72w-common php72w-devel php72w-gd php72w-pdo php72w-mysql php72w-mbstring php72w-bcmath
编译freeswitch 1.9
configure中间出现的错误:
configure: error: “Cannot build without libtiff (does your system require a libtiff-devel package?)”
yum install -y libtiff-devel
make中间出现的错误:
making all mod_signalwire
make[4]: Entering directory `/usr/local/src/freeswitch/src/mod/applications/mod_signalwire'
Makefile:916: *** You must install libks to build mod_signalwire. Stop.
make[4]: Leaving directory `/usr/local/src/freeswitch/src/mod/applications/mod_signalwire'
make[3]: *** [mod_signalwire-all] Error 1
本来想粗暴注释掉mod_signalwire解决,但逃避不是办法,解决一下吧
需要安装 libks 和 signalwire-c
https://github.com/signalwire/libks
https://github.com/signalwire/signalwire-c
libks需要cmake (Minimum version 3.6.2),比较坑,所以手动安装cmake
https://cmake.org/files/ 这里是编译安装,也可以自己下载编译好的直接用