freeswitch 安装指南 centos7.0
1.安装相关插件和库
yum -y install make gettext-devel expat-devel curl-devel zlib-devel openssl-devel bzip2 readline-devel libpcap-devel
yum install -y epel-release
yum install -y git gcc-c++ wget alsa-lib-devel autoconf automake bison broadvoice-devel bzip2 curl-devel db-devel e2fsprogs-devel flite-devel g722_1-devel 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 libtiff-devel libtheora-devel libtool libvorbis-devel libxml2-devel lua-devel lzo-devel mongo-c-driver-devel ncurses-devel net-snmp-devel openssl-devel opus-devel pcre pcre-devel perl perl-ExtUtils-Embed pkgconfig portaudio-devel postgresql-devel python26-devel python-devel soundtouch-devel speex speex-devel sqlite-devel unbound-devel unixODBC-devel libuuid-devel which yasm zlib-devel libatomic hiredis-devel
加载环境变量
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig/:/usr/local/lib64/pkgconfig/
Clone sofia-sip
cd /usr/src/freeswitch
git clone https://github.com/freeswitch/sofia-sip.git
cd sofia-sip
./bootstrap.sh -j
./configure
make
make install
ldconfig
安装spandsp
cd /usr/src/freeswitch
git clone https://github.com/freeswitch/spandsp.git
cd spandsp
./bootstrap.sh -j
./configure
make
make install
ldconfig
安装ffmpeg
rpm -ivh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
或
sudo yum localinstall --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm
yum install -y ffmpeg ffmpeg-devel
yum install -y ffmpeg ffmpeg-devel
安装opus
cd ..git clone https://freeswitch.org/stash/scm/sd/opus.git
wget https://archive.mozilla.org/pub/opus/opus-1.3.1.tar.gz
cd opus
./autogen.sh
./configure
make
make install
cp /usr/local/lib/pkgconfig/opus.pc /usr/lib64/pkgconfig
Create the repository config file /etc/yum.repos.d/linuxtech.repo:
[linuxtech]
name=LinuxTECH
baseurl=http://pkgrepo.linuxtech.net/el6/release/
enabled=1
gpgcheck=1
gpgkey=http://pkgrepo.linuxtech.net/el6/release/RPM-GPG-KEY-LinuxTECH.NET
yum install libopus-devel
安装完成之后要
cp /usr/local/lib/pkgconfig/opus.pc /usr/lib64/pkgconfig/
ln -s opus.pc libopus.pc
2.安装freeswitch和添加xml_curl
安装signalwire
安装cmake3.7
cd /usr/local/src
wget https://cmake.org/files/v3.7/cmake-3.7.2.tar.gz --no-check-certificate
cd cmake-3.7.2/
./bootstrap
gmake
gmake install
安装libks
yum install libatomic
cd /usr/local/src
git clone https://github.com/signalwire/libks.git
cd libks
cmake .
make
make install
安装signalwire-c
cd /usr/local/src
git clone https://github.com/signalwire/signalwire-c.git
cd signalwire-c/
cmake .
make
make install
ln -sf /usr/local/src/signalwire-c/signalwire_client.pc /usr/lib64/pkgconfig/signalwire_client.pc
设置代理
git config --global https.proxy http://127.0.0.1:10808
git config --global http.proxy http://127.0.0.1:10808
或
git config --global http.proxy socks5://yang:asd123456@127.0.0.1:10808
cd /usr/local/src
git clone https://github.com/signalwire/freeswitch
取消代理
git config --global --unset https.proxy
git config --global --unset http.proxy
cd freeswitch
./bootstrap.sh
./configure --enable-core-pgsql-support
## 错误: “You must install libopus-dev to build mod_opus.”
解决:
1.yum -y install opus-devel
2. make clean && ./configure && make
需要清理, 如果还是报这个错误
就注释这两行:
vi freeswitch/src/mod/codecs/mod_opus/Makefile
vim ./src/mod/codecs/mod_opus/Makefile
Comment line 896 & 897
#install: error
#all: error
make
vim modules.conf
取消
xml_int/mod_xml_cdr //话单
xml_int/mod_xml_curl //curl
mod_say_zh //说中文
make clean && ./configure --enable-core-pgsql-support && make
注释
make install
在freeswitch的安装目录下:/usr/local/freeswitch/conf/autoload_configs/xml_curl.conf.xml
在bindings里添加
freeswitch> load mod_xml_curl
//开启debug模式
freeswitch> xml_curl debug_on
中文语音包
一、中文语音资源的获取
1 官方提供的资源:https://coding.net/u/dujinfang/p/zh/git
二、中文资源的安装
1 英文资源的路径为conf/sounds/en/us/callie/...
2 类似的设置中文资源的路径为conf/sounds/zh/cn/link/...(link可以自己随意定义)
三、中文资源的配置
修改vars.xml如下:
1 52 <X-NO-PRE-PROCESS cmd="set" data="sound_prefix=$${sounds_dir}/en/us/callie"/> //屏蔽英文音频资源的路径设置
2 53 <X-PRE-PROCESS cmd="set" data="sound_prefix=$${sounds_dir}/zh/cn/link"/> //修改为中文音频资源的路径设置
增加vars.xml如下:
1 <X-PRE-PROCESS cmd="set" data="default_language=zh"/> //设置默认的语言
2 <X-PRE-PROCESS cmd="set" data="default_dialect=cn"/> //设置默认的方言
3 <X-PRE-PROCESS cmd="set" data="default_voice=link"/> //设置默认的声音
四、编译中文say模块
1. cd src/mod/say/mod_say_zh
2. make && make install
五、中文say的配置
1 cd conf/lang/
2 cp -fr en zh
3 cd zh
4 mv en.xml zh.xml
六、修改zh.xml为如下:
<language name="zh" say-module="zh" sound-prefix="$${sounds_dir}/zh/cn/link" tts-engine="mod_tts_commandline" tts-voice="Ting-Ting">
七、添加配置文件freeswitch.xml中文语言信息
<section name="languages" description="Language Management">
<X-PRE-PROCESS cmd="include" data="lang/de/*.xml"/>
<X-PRE-PROCESS cmd="include" data="lang/en/*.xml"/>
<X-PRE-PROCESS cmd="include" data="lang/zh/*.xml"/>
...
八、至此,中文提示音配置就全部结束了。
杂项
关闭防火墙
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)
设置时区
timedatectl set-timezone Asia/Shanghai //更改时区
关闭SELinux
修改/etc/selinux/config 文件
将SELINUX=enforcing改为SELINUX=disabled
加入环境变量
cd /usr/local/src/freeswitch/build/
cp freeswitch.service /lib/systemd/system/
chmod 750 /lib/systemd/system/freeswitch.service
cp freeswitch.sysconfig /etc/sysconfig/freeswitch
建立软连接
ln -sf /usr/local/freeswitch/bin/freeswitch /usr/bin/ ln -sf /usr/local/freeswitch/bin/fs_cli /usr/bin/
启动freeswitch
systemctl start freeswitch.service systemctl enable freeswitch.service
开机启动
1、赋予脚本可执行权限(/opt/script/autostart.sh是你的脚本路径)
chmod +x /opt/script/autostart.sh
2、打开/etc/rc.d/rc.local文件,在末尾增加如下内容
/opt/script/autostart.sh
3、在centos7中,/etc/rc.d/rc.local的权限被降低了,所以需要执行如下命令赋予其可执行权限
chmod +x /etc/rc.d/rc.local
安装mysql
1. 下载mysql的repo源
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
2. 安装mysql-community-release-el7-5.noarch.rpm包
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
3. 安装mysql
sudo yum install mysql-server
4设置允许远程访问
进入mysql
use mysql
查看用户状态:
SELECT User, Password, Host FROM user;
更改登录是否允许
UPDATE user SET Host='%' WHERE User='root' AND Host='localhost' LIMIT 1;
flush privileges;
导入数据库: 别忘了
安装并配置ODBC连接MySQL
yum install unixODBC unixODBC-devel libtool-ltdl libtool-ltdl-devel
安装mysql驱动:
yum install mysql-connector-odbc
修改文件
vim /etc/odbcinst.ini
Driver=/usr/lib/libmyodbc5w.so
Driver64=/usr/lib64/libmyodbc5w.so
vim /etc/odbc.ini
[MYSQLTP]Description=MySQL zwl database
Driver=MySQL
SERVER =127.0.0.1
PORT =3306
DATABASE = zwl
OPTION =67108864
CHARSET = UTF8
测试:
isql -v MYSQLTP root ''
安装php
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install php70w
yum install php70w-common php70w-fpm php70w-opcache php70w-gd php70w-mysqlnd php70w-mbstring php70w-pecl-redis php70w-pecl-memcached php70w-devel
安装apache
yum -y install httpd
设置开机启动
systemctl enable httpd.service
修改配置文件
cd /etc/httpd/conf
chmod -R 777 /var/www/html/
yum install php70w-pdo
yum install php70w-pdo_mysql
安装vsftpd
yum -y install vsftpd
设置开机启动
systemctl enable vsftpd.service
vim /etc/vsftpd/vsftpd.conf
加入
chroot_local_user=YES
chroot_list_enable=YES
allow_writeable_chroot=YES
anon_root=/tmp/record
加入定时任务
crontab -e
*/1 * * * * chmod -R 777 /tmp/record