FreeSWITCH安装

简介: FreeSWITCH

Build FreeSWITCH

这里主要介绍三种安装方法

  • Docker安装
  • 源码安装
  • 官网依赖安装

第一节 Docker 安装 FreeSwitch

1、Authentication required

最新FreeSwitch需要PAT才可以安装依赖。

SignalWire Personal Access Tokens (PAT)s are required to access FreeSWITCH install packages. HOWTO Create a SignalWire Personal Access Token

2、阿里源

由于使用debian默认的源是国外的,下载比较久,创建sources.list文件

cat >> sources.list <<-'EOF'
deb http://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb http://mirrors.aliyun.com/debian-security/ bullseye-security main
deb-src http://mirrors.aliyun.com/debian-security/ bullseye-security main
deb http://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
EOF

3、创建Dockerfile

这里我已经创建了账号,使用的时候请替换TOKEN

FROM debian:11.1

# 安装编译freeswitch,所需要依赖环境
ENV TOKEN=pat_CKj8GjohjcGkU3JEMsuAzfri
ADD ./sources.list /etc/apt/sources.list
RUN apt-get clean && apt-get update && apt-get install -yq gnupg2 wget lsb-release vim sngrep
RUN wget --http-user=andy --http-password=$TOKEN -O /usr/share/keyrings/signalwire-freeswitch-repo.gpg https://freeswitch.signalwire.com/repo/deb/debian-release/signalwire-freeswitch-repo.gpg
RUN echo "machine freeswitch.signalwire.com login andy password $TOKEN" > /etc/apt/auth.conf
RUN echo "deb [signed-by=/usr/share/keyrings/signalwire-freeswitch-repo.gpg] https://freeswitch.signalwire.com/repo/deb/debian-release/ `lsb_release -sc` main" > /etc/apt/sources.list.d/freeswitch.list
RUN echo "deb-src [signed-by=/usr/share/keyrings/signalwire-freeswitch-repo.gpg] https://freeswitch.signalwire.com/repo/deb/debian-release/ `lsb_release -sc` main" >> /etc/apt/sources.list.d/freeswitch.list
RUN apt-get update -y && apt-get build-dep freeswitch -y

# 需要把下载freeswitch-1.10.7.tar.gz,解压到Dockerfile文件同级目录下,添加到docker镜像里
#RUN wget https://files.freeswitch.org/releases/freeswitch/freeswitch-1.10.7.-release.tar.gz && tar -xzvf freeswitch-1.10.7.-release.tar.gz 
ADD ./freeswitch-1.10.7.-release.tar.gz /opt/

# 自定义安装freeswitch模块
COPY ./modules.conf /opt/freeswitch-1.10.7.-release/modules.conf
RUN cd /opt/freeswitch-1.10.7.-release && ./configure && make -j && make all install 
# RUN cd /opt/freeswitch-1.10.7.-release && ./configure && make -j && make all install &&  make cd-sounds-install cd-moh-install

#配置环境路径
#ENV PATH "/usr/local/freeswitch/bin:$PATH"

#修改配置信息
# ADD ./vars.xml /usr/local/freeswitch/conf/vars.xml  #修改密码、端口、IP等
# ADD ./switch.conf.xml /usr/local/freeswitch/conf/autoload_configs/switch.conf.xml  #端口
# ADD ./event_socket.conf.xml /usr/local/freeswitch/conf/autoload_configs/event_socket.conf.xml #esl链接密码

# 添加启动文件
ADD ./start.sh /start.sh
RUN chmod +x /start.sh

SHELL       ["/bin/bash"]
HEALTHCHECK --interval=15s --timeout=5s \
    CMD  /usr/local/freeswitch/bin/fs_cli -x status | grep -q ^UP || exit 1

CMD ["/start.sh"]

start.sh脚本

#!/bin/bash
set -e
exec /usr/local/freeswitch/bin/freeswitch

目录结构如下

目录结构

4、创建阿里云容器个人账号

阿里云官网容器镜像服务

5、创建Makefile

SHELL = /bin/bash
VERSION = 1.0.1

all:
    echo Hi

setup:
    if [[ ! -f .env ]]; then \
        cp env.example .env; \
    fi

run:
    docker-compose up -d

start:
    docker-compose up

bash:
    docker exec -it xswitch bash

cli:
    docker exec -it xswitch fs_cli

logs:
    docker logs -f --tail=100 xswitch

stop:
    docker stop xswitch

pull:
    docker pull registry.cn-hangzhou.aliyuncs.com/andy_wg/freeswitch:${VERSION}

.PHONY conf:
    docker cp xswitch:/usr/local/freeswitch/conf .

eject: conf
    echo conf copied to local dir, please edit docker-compose.yml to use it

get-sounds:
    wget -O sounds.zip https://xswitch.cn/download/sounds.zip
    unzip sounds.zip
    echo "edit docker-compose.yml to use it"

build:
    docker build -t xswitch .  

push:
    docker tag xswitch registry.cn-hangzhou.aliyuncs.com/andy_wg/freeswitch:${VERSION}
    docker push registry.cn-hangzhou.aliyuncs.com/andy_wg/freeswitch:${VERSION}

login:
    docker login --username=浪浪舒服 registry.cn-hangzhou.aliyuncs.com

get-ip:
    curl myip.ipip.net

6、生成镜像并上传阿里云

make build
make push

7、运行

宿主机目录:/data/freeswitch/conf,需要提前准备freeswitch的conf的配置。

docker run -it --network host --name freeswitch  -v /data/freeswitch/conf:/usr/local/freeswitch/conf -d freeswitch-1.10.7

8、安装CJSON

安装完FreeSwitch后,当启动lua调用json的时候会报错,这时需要安装下面的库

https://github.com/Kong/kong-cjson/archive/2.1.0.tar.gz

9、参考

第二节 源码安装

1、前提

安装方式可分为Docker安装和源码安装,推荐使用Docker安装

由于FreeSWITCH核心开发者大部分都使用Debian,在Debian上安装FreeSWITCH的方法见FreeSwitch官网

2、获取源码

3、安装

安装FreeSWITCH前需要安装一些依赖。在不同的平台上,依赖不同的包,如:

  • Debian/Ubuntu:
apt-get -y install build-essential subversion automake autoconf wget libtool libncurses5-dev
  • CentOS:
yum install -y git gcc-c++ yasm 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 libtiff-devel 

FreeSWITCH最新的源代码将Sofia-SIP和SpanDSP移出了FreeSWITCH代码仓库,分离到了独立的仓库中,在安装FreeSWITCH之前需要单独安装:

https://github.com/freeswitch/sofia-sip
https://github.com/freeswitch/spandsp

最新的mod\_verto模块也需要libks,源代码可以从以下地址获取:

https://github.com/signalwire/libks

重点:

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

获取FreeSwich源码

git clone https://github.com/signalwire/freeswitch.git

编译安装:

./bootstrap.sh # 初始化源码环境和工具
./configure    # 配置,如果将FreeSWITCH装到特定位置,可以使用 --prefix 指定
make           # 编译
make install   # 安装

创建软链接

ln -sf /usr/local/freeswitch/bin/freeswitch /usr/bin/ 
ln -sf /usr/local/freeswitch/bin/fs_cli /usr/bin/

4、参考链接

第三节 官网依赖安装

1、环境

操作系统:Centos7.4 FreeSwitch:1.10.7

2、提前

SpanDSP and sofia-sip
Sofia-sip and SpanDSP dependencies have been removed from the FreeSWITCH™ tree since v1.10.4 Release (05 August 2020).
You can find source files of Sofia-sip here: https://github.com/freeswitch/sofia-sip
SpanDSP sources are here: https://github.com/freeswitch/spandsp
Packages for Sofia-sip and SpandDSP are available for all supported platforms from our packaging repos.
You might have to visit each directory, run ./bootstrap.sh then ./configure then make install

3、源码安装

echo "signalwire" > /etc/yum/vars/signalwireusername
echo "pat_CKj8GjohjcGkU3JEMsuAzfri" > /etc/yum/vars/signalwiretoken
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*
 
scl enable devtoolset-4 'bash'
 
cd /usr/local/src
git clone -b v1.10 https://github.com/signalwire/freeswitch.git freeswitch
cd /usr/local/src/freeswitch
./bootstrap.sh -j
./configure --enable-portable-binary \
            --prefix=/usr --localstatedir=/var --sysconfdir=/etc \
            --with-gnu-ld --with-python --with-erlang --with-openssl \
            --enable-core-odbc-support --enable-zrtp
make
make -j install
make -j cd-sounds-install
make -j cd-moh-install
目录
相关文章
|
Linux 开发工具 git
FreeSWITCH小白入门之freeswitch安装篇
技术小白,今天带领大家一起freeswitch源码编译安装。我的上一篇文章已经搭建好了运行环境(centos7-Minimal),有人会说fs官方不是说在debian8下运行最稳定吗?我只能说,我个人爱好而已!
2803 0
|
Web App开发 存储 编解码
Freeswitch关于支持jsip的配置
1、freeswitch安装过程(安装过程省略,运行环境为centos7,freeswitch1.6.5)
|
3月前
|
关系型数据库 MySQL 数据库
debian11编译安装freeswitch
debian11编译安装freeswitch
|
Linux
CENTOS上编译FreeSwitch
CENTOS上编译FreeSwitch
135 0
|
编解码 网络协议 安全
freeswitch是什么
FreeSwitch是一个开源的电话软交换平台,是一个跨平台的/伸缩性极好的/免费的/多协议的电话软交换平台。同时FreeSWITCH是一个电话的软交换解决方案,包括一个软电话和软交换机用以提供语音和聊天的产品驱动。FreeSWITCH 可以用作交换机引擎、PBX、多媒体网关以及多媒体服务器等。
freeswitch是什么
|
安全 关系型数据库 MySQL
FreeSwitch的安装
本次安装环境是centos 7, 源码目录是
1501 1
|
Linux Perl
FreeSwitch 一些模块的安装
这里列出来 安装libyuv libvpx opus mod_av 等模块的代码方便大家使用
|
Linux 网络安全 开发工具
Centos7源代码安装FreeSwitch和启动FreeSwitch
1.下载源代码: 进入目录 cd /usr/local/src 克隆原代码 git clone -b v1.6 freeswitch.org/stash/scm/f… freeswitch
|
Ubuntu Linux Windows
FreeSWITCH安装需要什么环境
第一个问题需要我们考虑的是 : 我们需要什么样的操作系统 ?
|
XML 自然语言处理 搜索推荐
FreeSWITCH 与 Asterisk
Anthony Minssale/文 Seven/译