freeswitch 1.10.11在centos 7上需先替换阿里云源、启用sclo仓库并安装devtoolset-7;再按指定commit编译sofia-sip 1.13.17和spandsp(0d2e6ac65e);最后配置关闭非必需模块,用systemd管理服务并调高ulimit。

在AI电销机器人、WebRTC音视频会议和企业IP-PBX等融合通信场景中,需要一个稳定、可定制、支持SIP/WebRTC/IVR的软交换核心,FreeSWITCH 1.10.11正是当前生产环境广泛验证的成熟版本,它能承载数千路并发并提供ESL、Event Socket等关键集成接口。
系统环境初始化与依赖安装
先切换到root用户执行全部操作,避免权限中断导致编译失败:
sudo su -
替换CentOS 7默认源为阿里云镜像,并启用EPEL和SCLo仓库——这是后续所有依赖能正确解析的前提:
cd /etc/yum.repos.d && cp -p CentOS-Base.repo CentOS-Base.repo.bak && wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo && wget -O epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
手动修复已停服的centos-sclo源,否则yum install会卡死在“Cannot retrieve metalink”:
echo '[centos-sclo-rh]\nname=CentOS-7 - SCLo rh\nbaseurl=http://vault.centos.org/centos/7/sclo/\$basearch/rh/\ngpgcheck=1\nenabled=1\ngpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo' > /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
执行基础依赖安装,其中devtoolset-7是必须项,CentOS 7自带gcc 4.8.5无法编译1.10.11的新语法:
yum clean all && yum makecache && yum install -y epel-release centos-release-scl && yum install -y devtoolset-7-gcc* git wget zip unzip nasm yasm cmake3 libtool autoconf automake make python3-devel openssl-devel libcurl-devel pcre-devel speex-devel ldns-devel libedit-devel libxml2-devel libuuid-devel sqlite-devel zlib-devel ncurses-devel libjpeg-devel freetype-devel libpng-devel libsndfile-devel lua-devel
【务必执行 scl enable devtoolset-7 bash 启动新GCC环境,否则configure会因C++11特性报错】
第三方依赖模块编译安装
FreeSWITCH 1.10.11对sofia-sip和spandsp有强版本绑定,必须按指定commit编译,否则启动时mod_sofia加载失败或mod_spandsp崩溃:
方法一:sofia-sip(必须用1.13.17)
cd /root && git clone https://github.com/freeswitch/sofia-sip.git && cd sofia-sip && git checkout 1.13.17 && ./bootstrap.sh && ./configure --prefix=/usr/local && make && make install && ldconfig
方法二:spandsp(严禁使用master分支)
cd /root && git clone https://github.com/freeswitch/spandsp.git && cd spandsp && git checkout 0d2e6ac65e0e8f53d652665a743015a88bf048d4 && ./bootstrap.sh && ./configure --prefix=/usr/local && make && make install && ldconfig
注意:spandsp若用最新master,编译通过但运行时会触发V18_MODE_5BIT_4545未声明错误,直接导致freeswitch -nc启动失败。
FreeSWITCH主程序编译与安装
第一步:拉取官方源码并检出精确版本
cd /usr/local/src && git clone https://github.com/signalwire/freeswitch.git && cd freeswitch && git checkout v1.10.11
第二步:配置编译选项,关闭非必需模块减少冲突风险
./bootstrap.sh -j && ./configure --prefix=/usr/local/freeswitch --with-python=/usr/bin/python3 --enable-core-pyduns-support --disable-mod_av --disable-mod_lua --enable-mod_opus --enable-mod_sofia --enable-mod_dptools --enable-mod_event_socket --enable-mod_xml_cdr
第三步:编译并安装(耗时约12–25分钟,取决于CPU核心数)
make -j$(nproc) && make install && make cd-sounds-install && make cd-moh-install
第四步:创建专用运行用户并授权
useradd -r -s /sbin/nologin freeswitch && chown -R freeswitch:freeswitch /usr/local/freeswitch
服务配置与首次启动
将systemd服务文件复制到位并启用开机自启:
cp /usr/local/freeswitch/freeswitch.service /lib/systemd/system/ && systemctl daemon-reload && systemctl enable freeswitch
启动前必须设置ulimit,否则高并发下会出现“too many open files”错误:
echo "freeswitch soft nofile 65539" >> /etc/security/limits.conf && echo "freeswitch hard nofile 65539" >> /etc/security/limits.conf && echo "DefaultLimitNOFILE=65539" >> /etc/systemd/system.conf && systemctl daemon-reload
启动服务并检查状态:
systemctl start freeswitch && systemctl status freeswitch -l
验证控制台连通性:
fs_cli -x "status"











