Ubuntu 24.04 安装 Flexisip 2.6.2 指南

在 Ubuntu 24.04 用官方 APT 仓库安装 Flexisip 2.6.2,systemd 托管、REGISTER 端到端验证与排障实录。

FlexisipFlexisipSIP2026/10/25

Ubuntu 24.04 安装 Flexisip 2.6.2 指南

目标:在 Ubuntu 24.04 LTS 服务器上从零完成 Flexisip 2.6.2 的安装、systemd 托管与端到端注册验证。本文所有命令与回显均来自 2026-10-25 在 Ubuntu 24.04.5 LTS(x86_64)真实环境实测,排障过程一并沉淀。

一、环境信息

  • 操作系统:Ubuntu 24.04.5 LTS(Noble Numbat),x86_64
  • 软件版本:Flexisip 2.6.2-1(Belledonne 官方 APT 仓库 noble/stable 通道当前最新稳定版,2026-10-25 实查)
  • 依赖:libmariadb-dev 10.11.14(SQL 后端开发包)、iptables 1.8.10(DoS 防护模块需要)
  • 关键路径:二进制 /opt/belledonne-communications/bin/flexisip;配置 /etc/flexisip/flexisip.conf;日志 /var/opt/belledonne-communications/log/flexisip/;systemd 单元 /usr/lib/systemd/system/flexisip-*.service
  • 默认监听:SIP 5060/udp(默认 transports=sip:* 仅 UDP),STUN 3478/udp

二、前置条件

  1. 一台 Ubuntu 24.04 LTS 服务器,root 或 sudo 权限。
  2. 可访问 download.linphone.org(官方 APT 仓库)。2026-10-25 实测国内直连可达;若你的网络访问受限,可配置代理后重试。
  3. 硬件建议:官方要求按负载选择,1 万连接以内 8GB 内存起步(官方 Wiki Requirements,查询日期 2026-10-25)。
  4. 若启用 DoS 防护(默认启用),需要系统安装 iptables(见「八、常见问题」Q3)。

三、版本选型说明

Flexisip 官方按「发行版 × 大版本」提供预编译包。2026-10-25 实查官方支持矩阵与 APT 仓库,关键结论:

Flexisip 版本Ubuntu 22.04 (jammy)Ubuntu 24.04 (noble)Ubuntu 26.04Debian 12/13RockyLinux 8/9
2.4✓(最高 2.4.5)✓—✓✓
2.5已弃用(最高 2.5.3)✓—✓✓
2.6(当前稳定)✗(jammy 仓库无 2.6 包)✓(2.6.0~2.6.2)✓✓✓
2.7(alpha 预发布)✗✓✓✓✓
  • Ubuntu 22.04 用户注意:2.6 线官方不为 jammy 构建(jammy 仓库 stable/hotfix/beta 三通道实测最高仅 2.5.4 预发布),原因是 2.6 需要 C++20 工具链而 jammy 自带编译器过旧。要用 2.6.2 请使用 Ubuntu 24.04;如必须留在 22.04,只能装 2.5.3 或自行编译。
  • 版本号核实命令(以仓库为准,不要凭记忆写死):
apt-cache policy bc-flexisip

实测回显(noble/stable):

bc-flexisip:
  Installed: (none)
  Candidate: 2.6.2-1
  Version table:
     2.6.2-1 500
        500 https://download.linphone.org/snapshots/ubuntu noble/stable amd64 Packages
     2.6.1-1 500
        500 https://download.linphone.org/snapshots/ubuntu noble/stable amd64 Packages
     2.6.0-1 500
        500 https://download.linphone.org/snapshots/ubuntu noble/stable amd64 Packages
     2.5.3-1 500
        500 https://download.linphone.org/snapshots/ubuntu noble/stable amd64 Packages

💡 技术拓展:Flexisip 官方 APT 仓库分 stable / hotfix / beta / alpha 四个通道——stable 为正式发布;hotfix 是发布后的修复快照;beta/alpha 是预发布。生产只用 stable;官方要求即使启用其他通道也必须保留 stable,因为部分外部依赖只经 stable 通道分发。本文使用 stable。

四、方案 A:官方 APT 仓库在线安装(推荐)

这是官方主推方式,包内已带全部依赖库与 systemd 单元,5 分钟可完成。

4.1 添加 Belledonne 官方 APT 仓库

创建仓库定义文件:

echo "deb [arch=amd64] https://download.linphone.org/snapshots/ubuntu noble stable" > /etc/apt/sources.list.d/belledonne.list

导入仓库签名公钥:

wget -q https://download.linphone.org/snapshots/ubuntu/pubkey.gpg -O - | apt-key add -

实测回显:

Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
OK

⚠️ 注意:apt-key 已被 apt 标记为弃用(仅警告,不影响本次安装)。想走新式 keyring 写法可用 wget -q https://download.linphone.org/snapshots/ubuntu/pubkey.gpg -O - | gpg --dearmor -o /usr/share/keyrings/belledonne-archive-keyring.gpg,并在仓库行加 signed-by=/usr/share/keyrings/belledonne-archive-keyring.gpg。官方 Wiki 目前仍给出 apt-key 写法,两种均可。

刷新索引:

apt-get update

实测回显(节选,实测首尾):

Get:17 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Packages [1733 kB]
...
Fetched 33.6 MB in 32s (1047 kB/s)
Reading package lists...
W: https://download.linphone.org/snapshots/ubuntu/dists/noble/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.

4.2 安装 SQL 后端开发包(官方建议)

Flexisip 的认证/消息库等模块通过 SOCI 连接 MySQL/MariaDB,官方 Wiki 明确要求先装开发包,否则运行期会报 [SOCI] connection pool open error: Failed to find shared library for backend mysql:

apt-get install -y --no-install-recommends libmariadb-dev

实测回显(节选):

Setting up zlib1g-dev:amd64 (1:1.3.dfsg-3.1ubuntu2.3) ...
Setting up libmariadb-dev (1:10.11.14-0ubuntu0.24.04.1) ...
Processing triggers for libc-bin (2.39-0ubuntu8.9) ...

4.3 安装 bc-flexisip 主包

apt-get install -y --no-install-recommends bc-flexisip

实测回显(节选,实测首尾):

Setting up python3-requests (2.31.0+dfsg-1ubuntu1.2) ...
...
Setting up bc-flexisip (2.6.2-1) ...
Processing triggers for systemd (255.4-1ubuntu8.18) ...

💡 说明:bc-flexisip 是一个聚合包(Provides 里带 bc-bctoolbox、bc-belle-sip、bc-sofia-sip、bc-soci、bc-hiredis 等 Belledonne 全家桶依赖),同时附带 Python 写的管理工具 flexisip_cli.py(依赖 python3-requests 等,apt 已自动安装)。

4.4 安装结果核对

dpkg -s bc-flexisip | grep -E "^(Package|Version|Installed-Size|Maintainer|Architecture)"

实测回显:

Package: bc-flexisip
Installed-Size: 69215
Maintainer: info@belledonne-communications.com
Architecture: amd64
Version: 2.6.2-1

查看安装的可执行文件与 systemd 单元:

ls /opt/belledonne-communications/bin/
ls /usr/lib/systemd/system/ | grep flexisip

实测回显:

flexisip
flexisip_cli.py
flexisip_pusher
linphone-daemon
linphone-daemon-pipetest
flexisip-b2bua.service
flexisip-b2bua@.service
flexisip-linphone-daemon.service
flexisip-presence.service
flexisip-presence@.service
flexisip-proxy.service
flexisip-proxy@.service
flexisip-regevent.service
flexisip-regevent@.service
flexisip-voicemail.service
flexisip-voicemail@.service

查看版本与编译特性:

/opt/belledonne-communications/bin/flexisip --version

实测回显:

/opt/belledonne-communications/bin/flexisip  version: 2.6.2 (sofia-sip: 1.13.45bc-70-g5c6c07ea2) compiled with SNMP - Transcoder - Redis - Soci - Presence - RegEvent - B2BUA - Voicemail

4.5 配置文件说明

2.3 版本起,安装包已自动落盘默认配置 /etc/flexisip/flexisip.conf(首行即 This is the default Flexisip (v2.6.2) configuration file),共 2762 行、全部参数以注释形式给出文档与默认值。如需重新生成全新默认配置:

/opt/belledonne-communications/bin/flexisip --dump-default all > /etc/flexisip/flexisip.conf.new

默认配置下 Flexisip 表现为「简单转发代理」,Registrar 模块只受理 localhost 域的注册(reg-domains 默认值),默认监听 sip:*(UDP 5060)。要服务自有域名,编辑 /etc/flexisip/flexisip.conf,把 module::Registrar 段的 #reg-domains=localhost 改为你的域名列表(空格分隔),并按需在 global 段追加 sips:* 或 sip:0.0.0.0:5060;transport=tcp 等 transports。参数逐段详解见本站《Flexisip 2.6 配置参数详解》。

4.6 systemd 托管与开机自启

systemctl enable flexisip-proxy
systemctl start flexisip-proxy

实测回显:

Created symlink /etc/systemd/system/multi-user.target.wants/flexisip-proxy.service → /usr/lib/systemd/system/flexisip-proxy.service.

查看运行状态:

systemctl status flexisip-proxy --no-pager

实测回显(节选):

● flexisip-proxy.service - Flexisip proxy server
     Loaded: loaded (/usr/lib/systemd/system/flexisip-proxy.service; enabled; preset: enabled)
     Active: active (running) since Sun 2026-10-25 07:08:53 UTC; 2s ago
       Docs: https://www.linphone.org/en/flexisip-sip-server/
   Main PID: 1355 (flexisip)
      Tasks: 4 (limit: 3612)
     Memory: 6.4M (peak: 7.3M)
             └─1355 /opt/belledonne-communications/bin/flexisip --server proxy --disable-stdout --syslog --pidfile /var/run/flexisip-proxy.pid

Oct 25 07:08:53 flexisip-srv01 flexisip[1355]: Flexisip::main - Starting Flexisip-proxy server [version: 2.6.2]

确认监听端口:

ss -lnup | grep -E "5060|3478"

实测回显:

UNCONN 0      0            0.0.0.0:3478       0.0.0.0:*    users:(("flexisip",pid=1355,fd=29))
UNCONN 0      0          127.0.0.1:5060       0.0.0.0:*    users:(("flexisip",pid=1355,fd=11))
UNCONN 0      0         10.89.74.2:5060       0.0.0.0:*    users:(("flexisip",pid=1355,fd=9))
UNCONN 0      0              [::1]:5060          [::]:*    users:(("flexisip",pid=1355,fd=13))

💡 说明:sip:* 表示在全部本机地址上监听 UDP 5060;3478/udp 是内置 STUN 服务(NAT 穿透用)。需要 TCP/TLS 时再改 global/transports。

4.7 端到端验证:注册一个账号

向本机代理发一条 REGISTER(域用默认受理的 localhost),能用任何 SIP 客户端;这里用一段 Python 直接发包验证(无需额外安装):

python3 -c "
import socket
msg = \"REGISTER sip:localhost SIP/2.0\r\nVia: SIP/2.0/UDP 127.0.0.1:59999;branch=z9hG4bK-reg02;rport\r\nFrom: <sip:alice@localhost>;tag=2001\r\nTo: <sip:alice@localhost>\r\nCall-ID: reg-002@127.0.0.1\r\nCSeq: 1 REGISTER\r\nContact: <sip:alice@127.0.0.1:59999>\r\nExpires: 3600\r\nMax-Forwards: 5\r\nContent-Length: 0\r\n\r\n\"
s=socket.socket(socket.AF_INET, socket.SOCK_DGRAM); s.settimeout(3)
s.sendto(msg.encode(), (\"127.0.0.1\",5060))
print(s.recvfrom(4096)[0].decode())
"

实测回显(200 注册成功,服务横幅可见版本):

SIP/2.0 200 Registration successful
Via: SIP/2.0/UDP 127.0.0.1:59999;branch=z9hG4bK-reg02;rport=49857
From: <sip:alice@localhost>;tag=2001
To: <sip:alice@localhost>;tag=FXvQt3rjjvXDp
Call-ID: reg-002@127.0.0.1
CSeq: 1 REGISTER
Contact: <sip:alice@127.0.0.1:49857>
Expires: 3600
Server: Flexisip/2.6.2 (sofia-sip-nta/2.0)
Supported: path, outbound
Content-Length: 0

再用管理 CLI 核对注册库确实写入了(CLI 逐命令详解见《Flexisip 2.6.2 常用 CLI 命令与工具详解》):

python3 /opt/belledonne-communications/bin/flexisip_cli.py REGISTRAR_DUMP

实测回显:

{
  "aors": [
    "alice@localhost"
  ]
}

至此安装与最小验证完成。

五、方案 B:源码编译安装(备用)

适用于仓库未覆盖的发行版、需要定制编译选项(如关闭 Presence、启用 Sanitizer)或追上游修复的场景。Flexisip 2.6 使用 C++20,编译器门槛较高:GCC ≥ 13 或 Clang ≥ 19(Ubuntu 24.04 默认 GCC 13 满足;Debian 12 的 GCC 太旧只能用 Clang——官方 README 明示)。流程要点(来源:官方 README,查询日期 2026-10-25):

# 1. 拉源码(递归子模块,-b 指定标签或 release 分支)
git clone https://gitlab.linphone.org/BC/public/flexisip --recursive -b 2.6.2
cd flexisip

# 2. 配置并编译(make -j 按 CPU 核数调整)
mkdir ./build
cmake -S . -B ./build
make -C ./build -j4

# 3. 需要打包成 deb 再安装时:
cmake ./build -DCMAKE_INSTALL_PREFIX=/opt/belledonne-communications -DCMAKE_BUILD_TYPE=RelWithDebInfo -DSYSCONF_INSTALL_DIR=/etc -DFLEXISIP_SYSTEMD_INSTALL_DIR=/usr/lib/systemd/system -DCPACK_GENERATOR=DEB
make -C ./build -j4 package

⚠️ 注意:编译需先装齐依赖(OpenSSL、nghttp2、libsrtp2、SQLite3、libmysql-client、XercesC、jsoncpp、hiredis、libsystemd 等,完整依赖表见官方 README「Dependencies」一节),且 linphone-sdk 子模块体量大、编译耗时长(数十分钟级),仅推荐有定制需求时使用。常用裁剪项如 cmake ./build -DENABLE_PRESENCE=OFF 可关闭 Presence 服务。

六、方案对比与选择建议

维度方案 A:官方 APT 仓库方案 B:源码编译
是否需要外网安装时需要拉源码时需要
上手耗时约 5 分钟数十分钟(含依赖编译)
systemd 单元包自带打包时指定目录生成
版本可控性跟随仓库通道任意 tag/分支
可定制性固定编译特性(SNMP/Redis/B2BUA 等已启用)可裁剪模块、改优化级别
适用场景绝大多数生产/测试环境定制编译、未覆盖发行版、二次开发

选择建议:能用 APT 仓库就用方案 A;只有在仓库没有你的发行版、或必须修改编译选项时才走方案 B。

七、配置说明

  • 主配置:/etc/flexisip/flexisip.conf(INI 格式,[global]/[cluster]/[module::XXX] 等段;每参数带官方注释与默认值,全部注释掉即全默认)。
  • 运行时改参:多数参数可用 python3 /opt/belledonne-communications/bin/flexisip_cli.py CONFIG_SET <段>/<参数> <值> 在线热改,如 CONFIG_SET global/log-level debug 立即生效;配置文件与热改的关系、全参数表见《Flexisip 2.6 配置参数详解》。
  • 日志:/var/opt/belledonne-communications/log/flexisip/flexisip-proxy.log,默认级别 error,排障时可热改为 debug。
  • 防火墙放行清单(最小开放):5060/udp(SIP)、5060/tcp 与 5061/tcp(启用 TCP/TLS 时)、3478/udp(内置 STUN)、媒体中继 UDP 端口段(module::MediaRelay/sdp-port-range,默认 1024-65535,生产建议收窄)。

八、常见问题

Q1:安装后日志里反复出现 '/sbin/iptables ... failed ... not found'?

实测现象:启动后 flexisip-proxy.log 报 /sbin/iptables: not found。原因:Flexisip 启动时会为 DoS 防护建立 FLEXISIP iptables 链,最小化系统未装 iptables。解决:

apt-get install -y --no-install-recommends iptables
systemctl restart flexisip-proxy

实测安装后链建立成功:

Chain FLEXISIP (1 references)
target     prot opt source               destination

(首次重启仍可能看到一条 No chain/target/match by that name,是「先 flush 后建链」的顺序性提示,链随后已正常建立,可忽略。)

Q2:向代理发 OPTIONS/REGISTER 没有任何响应?

实测排查:默认配置下 Flexisip 是「纯转发代理」——module::Registrar/reg-domains 默认只受理 localhost 域;发往其他域的消息会经 Router→Forward 继续向外转发(转发不出去就静默超时),代理本身不应答。两个结论:① 本机验证时 REGISTER 的域名部分必须用 localhost(如 sip:alice@localhost);② 生产环境把 reg-domains 改成你的 SIP 域,并相应配置 global/aliases。用 flexisip_cli.py CONFIG_SET global/log-level debug 开调试日志可逐模块观察消息流转。

Q3:认证接 MySQL 报 [SOCI] connection pool open error: Failed to find shared library for backend mysql?

官方 Wiki 明示:安装 bc-flexisip 前先装 libmariadb-dev(本文 4.2 已含此步),SOCI 的 MySQL 后端动态库由它提供。

Q4:apt-key 警告 apt-key is deprecated?

仅警告不影响安装,见 4.1 的 ⚠️ 说明与新式 keyring 替代写法。

Q5:如何查看当前生效的某个配置值?

python3 /opt/belledonne-communications/bin/flexisip_cli.py CONFIG_GET global/transports

实测回显:global/transports: sip:*。

九、升级与回滚

升级前记录当前版本(用于回滚):

dpkg -s bc-flexisip | grep ^Version

实测回显:Version: 2.6.2-1

执行升级并重启服务:

apt-get update && apt-get install -y --only-upgrade bc-flexisip
systemctl restart flexisip-proxy
systemctl is-active flexisip-proxy

回滚到指定版本(版本号以 apt-cache policy bc-flexisip 列出的为准):

apt-get update && apt-get install -y bc-flexisip=2.6.1-1
systemctl restart flexisip-proxy

⚠️ 注意:从 2.5 及更早版本升级到 2.6+ 且使用会议服务器功能的,必须先读官方《Flexisip 2.5 to 2.6 migration guide》——会议服务器自 2.6 起拆分为独立软件包。

十、卸载与清理

systemctl stop flexisip-proxy
systemctl disable flexisip-proxy
apt-get purge -y bc-flexisip
rm -rf /etc/flexisip /var/opt/belledonne-communications /var/run/flexisip-*.pid
rm -f /etc/apt/sources.list.d/belledonne.list
apt-get update

十一、参考链接