Centos7安装FreeSWITCH脚本
FreeSWITCH版本
1.10.9
建议使用Centos7.6 发行版安装,外网网络速度对安装进度有较大影响
配置token
# 这个token是要到signalwire官网去申请的,建议自己去申请一个
echo "token" > /etc/yum/vars/signalwiretoken
echo "username" > /etc/yum/vars/signalwireusername
开始安装
# 配合上面的token,组装成安装地址
yum install -y https://$(< /etc/yum/vars/signalwireusername):$(< /etc/yum/vars/signalwiretoken)@freeswitch.signalwire.com/repo/yum/centos-release/freeswitch-release-repo-0-1.noarch.rpm epel-release
yum-builddep -y freeswitch
yum install -y yum-plugin-ovl centos-release-scl rpmdevtools yum-utils git
yum install -y devtoolset-4-gcc*
开始下载需要编译的源代码
wget https://github.com/signalwire/freeswitch/archive/refs/tags/v1.10.9.tar.gz
# 解压缩代码
tar -zxvf v1.10.9.tar.gz
# 解压缩后的默认名称
cd freeswitch-1.10.9
yum install libpq-devel
安装自动配置
# 安装各种依赖
yum install libtool
yum install -y git alsa-lib-devel autoconf automake bison broadvoice-devel bzip2 curl-devel libdb4-devel e2fsprogs-devel erlang flite-devel g722_1-devel gcc-c++ 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 libtheora-devel libtiff-devel
安装PostgresSQL,只有需要修改内核数据库为pg库才需要安装
# 配置postgresql映射地址
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# 安装postgresql-12 建议大于9.5
sudo yum install -y postgresql12 postgresql12-server
# 防火墙添加pg库规则
sudo firewall-cmd --add-port=5432/tcp --permanent
# 初始化数据库
sudo /usr/pgsql-12/bin/postgresql-12-setup initdb
# 启动服务
sudo systemctl start postgresql-12
sudo systemctl enable postgresql-12
# 切换到数据库用户
su postgres
psql
# 设置密码
ALTER USER postgres WITH PASSWORD 'passwd';
# 创建数据库
create database freeswitch;
#退出数据库控制台
\q
#退出当前postgres用户
exit
安装FreeSWITCH依赖
# 回到freeswitch目录
cd freeswitch-1.10.9/
# 安装sofia
git clone https://github.com/freeswitch/sofia-sip.git
cd sofia-sip
./bootstrap.sh
./configure
make
make install
cd ..
# 安装spandsp
git clone https://github.com/freeswitch/spandsp
cd spandsp
./bootstrap.sh
./configure
make
make install
#修改配置文件映射
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
继续安装FreeSWITCH
cd freeswitch-1.10.9/
# 开始编译FreeSWITCH
./bootstrap.sh -j
# 配置编译参数 --enable-core-pgsql-support 这个参数只有需要通过内核直连pg库的时候才添加
./configure --enable-portable-binary --prefix=/usr --localstatedir=/var --sysconfdir=/etc --with-gnu-ld --with-python --with-erlang --with-openssl --enable-core-odbc-support --enable-core-pgsql-support --enable-zrtp
make
# 安装声音文件
make -j cd-sounds-install
/usr/local/src/freeswitch-1.10.9/build/getsounds.sh freeswitch-sounds-en-us-callie-16000-1.0.53.tar.gz /usr/share/freeswitch/sounds/
/usr/local/src/freeswitch-1.10.9/build/getsounds.sh freeswitch-sounds-en-us-callie-8000-1.0.53.tar.gz /usr/share/freeswitch/sounds/
/usr/local/src/freeswitch-1.10.9/build/getsounds.sh freeswitch-sounds-en-us-callie-32000-1.0.53.tar.gz /usr/share/freeswitch/sounds/
/usr/local/src/freeswitch-1.10.9/build/getsounds.sh freeswitch-sounds-en-us-callie-48000-1.0.53.tar.gz /usr/share/freeswitch/sounds/
# 安装音乐文件
make -j cd-moh-install
/usr/local/src/freeswitch-1.10.9/build/getsounds.sh freeswitch-sounds-music-16000-1.0.52.tar.gz /usr/share/freeswitch/sounds/
/usr/local/src/freeswitch-1.10.9/build/getsounds.sh freeswitch-sounds-music-32000-1.0.52.tar.gz /usr/share/freeswitch/sounds/
/usr/local/src/freeswitch-1.10.9/build/getsounds.sh freeswitch-sounds-music-8000-1.0.52.tar.gz /usr/share/freeswitch/sounds/
/usr/local/src/freeswitch-1.10.9/build/getsounds.sh freeswitch-sounds-music-48000-1.0.52.tar.gz /usr/share/freeswitch/sounds/
# 服务随系统自动启动
service freeswitch enable
# 启动服务
service freeswitch start
# 检查服务状态
service freeswitch status
# 检查端口占用情况,判断服务是否正常启动
netstat -tunlp | grep 5060
# 进入FreeSWITCH控制台
fs_cli
PostgreSQL数据库环境配置会在另外的文档说明