freeswitch通过编译方式安装

阿里云轻量服务器Ubuntu 24.04.2 LTS + freeswitch 1.10.12-release

说明:freeswitch是模块化的,如果编译的过程中报错,可以预先注释跳过。

源码下载

将代码统一下载到 /opt 目录下

shell 复制代码
# 下载FreeSWITCH源码 
git clone -b v1.10 https://github.com/signalwire/freeswitch freeswitch 
# 下载sofia-sip源码 
git clone https://github.com/freeswitch/sofia-sip 
# 下载spandsp源码 
git clone https://github.com/freeswitch/spandsp

# 下载libks源码(不需要signalwire这个的话,这个也可以不装) 
git clone https://github.com/signalwire/libks 
# 下载signalwire-c源码(不需要可以不安装) 
git clone https://github.com/signalwire/signalwire-c

安装必要依赖

有些可能也不需要

bash 复制代码
sudo apt-get install -y \
    build-essential cmake automake autoconf libtool libtool-bin pkg-config \
    libssl-dev zlib1g-dev libdb-dev unixodbc-dev libncurses5-dev libexpat1-dev libgdbm-dev bison erlang-dev libtpl-dev libtiff5-dev uuid-dev \
    libpcre3-dev libedit-dev libsqlite3-dev libcurl4-openssl-dev nasm \
    libogg-dev libspeex-dev libspeexdsp-dev \
    libldns-dev \
    python3-dev \
    libavformat-dev libswscale-dev libavresample-dev \
    liblua5.2-dev \
    libopus-dev \
    libpq-dev \
    libshout3-dev libmpg123-dev libmp3lame-dev \
    libsndfile1-dev libflac-dev libogg-dev libvorbis-dev

安装sofia-sip

bash 复制代码
cd sofia-sip
./bootstrap.sh
./configure CFLAGS="-g -ggdb" --with-pic --with-glib=no --without-doxygen --disable-stun --prefix=/usr
make -j`nproc --all`
sudo make install
cd ..

安装spandsp

bash 复制代码
cd spandsp
./bootstrap.sh
./configure CFLAGS="-g -ggdb" --with-pic --prefix=/usr
make -j`nproc --all`
sudo make install
cd ..

安装libks(可选)

bash 复制代码
cd libks
cmake . -DCMAKE_INSTALL_PREFIX=/usr -DWITH_LIBBACKTRACE=1
sudo make install
cd ..

安装signalwire-c(可选)

bash 复制代码
cd signalwire-c
PKG_CONFIG_PATH=/usr/lib/pkgconfig cmake . -DCMAKE_INSTALL_PREFIX=/usr
sudo make install
cd ..

编译安装freeswitch

如果没有安装signalwire-c,可以在执行./configure后,注释modules.conf中的applications/mod_signalwire

在安装过程中提示libavformat报错,分析发现与mod_av模块相关,注释modules.conf中的applications/mod_av跳过报错

bash 复制代码
cd freeswitch
./bootstrap.sh -j
./configure
make -j`nproc`
sudo make install

启动FreeSWITCH服务

执行以上步骤后,FreeSWITCH已经被安装到/usr/local/freeswitch目录下了。

bash 复制代码
cd /usr/local/freeswitch
# 前台启动服务
bin/freeswitch
# 后台启动服务
bin/freeswitch -nc

使用linphone进行测试

不介绍linphone软件上的配置

拨打9196可以接通,但是听不到回音

开放端口

之前只在阿里云的安全规则中放行了5060端口,所以可以接通。需要在安全规则中添加16384-32768端口的UDP放行规则

端口范围 协议 备注
5060 TCP&UDP 用于 SIP 信令
16384-32768 UDP 用于 SIP、交换以及其他协议的语音或视频的数据传输

注:5060端口可以在/usr/local/freeswitch/conf/vars.xml 中修改 <X-PRE-PROCESS cmd="set" data="internal_sip_port=5060"/>

修改internal.xml

因为是跨网络,打通以后需要设置统一的sip网络/usr/local/freeswitch/conf/sip_profiles/internal.xmlext-rtp-ipext-sip-ip设置为公网地址

拨打9664不播放音乐

检查/usr/local/freeswitch/sounds没有下载音乐包

进入/opt/freeswitch文件夹,下载声音文件。执行其中一种就可以

bash 复制代码
# cd 音质声音文件
make cd-sounds-install
make cd-moh-install
#超高清声音文件
make uhd-sounds-install
make uhd-moh-install
#高清声音文件
make hd-sounds-install
make hd-moh-install
#标准声音文件
make sounds-install
make moh-install

执行完成后在/usr/local/freeswitch/sounds执行tree -L 4,效果如下图:

相关推荐
GetcharZp3 小时前
GitHub 49K+ Star!C++ 开发者必知的 JSON 神级库:从零到精通全指北
后端
xujinwei_gingko4 小时前
SpringBoot整合WebSocket
spring boot·后端·websocket
智码看视界4 小时前
现代Web开发基础:全栈工程师的起航点
前端·后端·c5全栈
程序员cxuan4 小时前
Claude Fable 5 来了
人工智能·后端·程序员
JS菌4 小时前
手写一个 AI Agent 全栈项目:从沙箱执行到子智能体的完整实现
前端·人工智能·后端
wang09075 小时前
自己动手写一个spring之IOC_2
java·后端·spring
ltl5 小时前
推理退化:为什么大模型会输出乱码、死循环和无意义文本
后端
ltl5 小时前
架构视图与文档:C4 模型从入门到实战
后端
IT_陈寒8 小时前
Redis持久化这个坑,我爬了一整天才出来
前端·人工智能·后端
无风听海8 小时前
多租户系统中的 OIDC:Discovery 端点与联合登录的深度实践
后端·python·flask