一、添加第三方源
echo "deb http://us.archive.ubuntu.com/ubuntu/ xenial multiverse" >> /etc/apt/source.list
echo "deb-src http://us.archive.ubuntu.com/ubuntu/ xenial multiverse">> /etc/apt/source.list
echo "deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates multiverse" >> /etc/apt/source.list
echo "deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates multiverse" >> /etc/apt/source.list
echo "deb http://cz.archive.ubuntu.com/ubuntu xenial main universe" >> /etc/apt/source.list
二、安装Video LAN程序包
apt-get update
apt-get install -y software-properties-common tzdata
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
add-apt-repository ppa:videolan/stable-daily
三、安装部分依赖包
apt-get update && apt-get install -y autoconf automake bison build-essential fail2ban gawk git-core groff groff-base erlang-dev libasound2-dev libavcodec-dev libavutil-dev libavformat-dev libav-tools libavresample-dev libswscale-dev liba52-0.7.4-dev libssl-dev libdb-dev libexpat1-dev libcurl4-openssl-dev libgdbm-dev libgnutls-dev libjpeg-dev libmp3lame-dev libncurses5 libncurses5-dev libperl-dev libogg-dev libsnmp-dev libtiff5-dev libtool libvorbis-dev libx11-dev libzrtpcpp-dev make portaudio19-dev python-dev snmp snmpd subversion unixodbc unixodbc-dev uuid-dev zlib1g-dev libsqlite3-dev libpcre3-dev libspeex-dev libspeexdsp-dev libldns-dev libedit-dev libladspa-ocaml-dev libmemcached-dev libmp4v2-dev libpq-dev libvlc-dev libv8-dev liblua5.2-dev libyaml-dev libpython-dev odbc-postgresql sendmail wget yasm libldap2-dev libcodec2-dev vim net-tools nmap
四、配置使用gawk
update-alternatives --set awk /usr/bin/gawk
五、编译安装程序依赖包
1.安装cmake
# mkdir /opt/software
# wget https://github.com/Kitware/CMake/releases/download/v3.17.2/cmake-3.17.2.tar.gz -P /opt/software
# cd /opt/software
# tar -zxvf cmake-3.17.2.tar.gz
# cd cmake-3.7.2
./bootstrap --prefix=/usr
make && make install
2.安装libks
# git clone https://github.com/signalwire/libks.git /opt/software/
# cd /opt/software/libks
cmake .
make && make install
3.安装signalwire-c
# git clone https://github.com/signalwire/signalwire-c.git /opt/software
# cd /opt/software/signalwire-c
cmake .
make && make install
4.安装mod_mariadb依赖包
# wget https://downloads.mariadb.com/Connectors/c/connector-c-3.1.7/mariadb-connector-c-3.1.7-linux-x86_64.tar.gz -P /opt/software
# cd /opt/software
# tar -zxvf mariadb-connector-c-3.1.7-linux-x86_64.tar.gz
cp -r mariadb-connector-c-3.1.7-linux-x86_64/include/mariadb/* /usr/include
cp -r mariadb-connector-c-3.1.7-linux-x86_64/lib/mariadb/* /lib/x86_64-linux-gnu/
# export PKG_CONFIG_PATH=/opt/software/mariadb-connector-c-3.1.7-linux-x86_64/lib/pkgconfig
5.安装mysql数据库连接程序
# tar -zxvf mysql-connector-odbc-8.0.19-linux-ubuntu16.04-x86-64bit.tar.gz
cp -r mysql-connector-odbc-8.0.19-linux-ubuntu16.04-x86-64bit/lib/* /usr/lib/x86_64-linux-gnu/odbc/
ln -sf /usr/lib/x86_64-linux-gnu/odbc/libmyodbc8a.so /usr/lib/
ln -sf /usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so /usr/lib/
6.安装freeswitch编译部分依赖包
# GIT_SSL_NO_VERIFY=1
# git clone https://github.com/BetterVoice/freeswitch-container.git /opt/software
# sh /opt/software/freeswitch-container/build/install-deps.sh
六、编制安装freeswitch 1.10
# git clone https://github.com/signalwire/freeswitch.git -b v1.10 /opt/software
# cd /opt/software/freeswitch
./bootstrap.sh
./configure --prefix=/opt/freeswitch --with-gnu-ld --with-python --with-erlang --with-openssl --enable-portable-binary --enable-core-odbc-support --enable-zrtp
make && make install
make uhd-sounds-install //标准提示音
make uhd-moh-install //标准通话音乐
cp src/mod/databases/mod_mariadb/.libs/mod_mariadb.so /opt/freeswitch/lib/freeswitch/mod/
cp -rf debian/freeswitch-sysvinit.freeswitch.default /etc/default/freeswitch
七、添加SIP 48000Hz音频程序
# tar -zxvf freeswitch-sounds-en-us-callie-48000-1.0.52.tar.gz -C /opt/software
# tar -zxvf freeswitch-sounds-music-48000-1.0.52.tar.gz -C /opt/software
# cd /opt/software
cp -r sounds/en/us/callie/ascii/48000 /opt/freeswitch/share/freeswitch/sounds/en/us/callie/ascii/
cp -r sounds/en/us/callie/base256/48000 /opt/freeswitch/share/freeswitch/sounds/en/us/callie/base256/
cp -r sounds/en/us/callie/conference/48000 /opt/freeswitch/share/freeswitch/sounds/en/us/callie/conference/
cp -r sounds/en/us/callie/currency/48000 /opt/freeswitch/share/freeswitch/sounds/en/us/callie/currency/
cp -r sounds/en/us/callie/digits/48000 /opt/freeswitch/share/freeswitch/sounds/en/us/callie/digits/
cp -r sounds/en/us/callie/directory/48000 /opt/freeswitch/share/freeswitch/sounds/en/us/callie/directory/
cp -r sounds/en/us/callie/ivr/48000 /opt/freeswitch/share/freeswitch/sounds/en/us/callie/ivr/
cp -r sounds/en/us/callie/misc/48000 /opt/freeswitch/share/freeswitch/sounds/en/us/callie/misc/
cp -r sounds/en/us/callie/phonetic-ascii/48000 /opt/freeswitch/share/freeswitch/sounds/en/us/callie/phonetic-ascii/
cp -r sounds/en/us/callie/time/48000 /opt/freeswitch/share/freeswitch/sounds/en/us/callie/time/
cp -r sounds/en/us/callie/voicemail/48000 /opt/freeswitch/share/freeswitch/sounds/en/us/callie/voicemail/
cp -r sounds/en/us/callie/zrtp/48000 /opt/freeswitch/share/freeswitch/sounds/en/us/callie/zrtp/
cp -r sounds/music/48000 /opt/freeswitch/share/freeswitch/sounds/music/
八、添加freeswitch用户
# adduser --disabled-password --quiet --system --home /opt/freeswitch --gecos "FreeSwitch Voice Platform" --ingroup daemon freeswitch && adduser freeswitch audio
# chown -R freeswitch:daemon /opt/freeswitch && chmod -R o-rwx /opt/freeswitch
# ln -s /opt/freeswitch/bin/freeswitch /usr/bin/
# ln -s /opt/freeswitch/bin/fs_cli /usr/bin/
九、禁用freeswitch IPv6功能
# mv /opt/freeswitch/etc/freeswitch/sip_profiles/external-ipv6.xml /opt/freeswitch/etc/freeswitch/sip_profiles/external-ipv6.xml-bak
# mv /opt/freeswitch/etc/freeswitch/sip_profiles/internal-ipv6.xml /opt/freeswitch/etc/freeswitch/sip_profiles/internal-ipv6.xml-bak
十、配置ODBC连接
# cat > /etc/odbcinst.ini < /etc/odbc.ini <
改为
十一、修改RTP语音通话UDP端口范围
# vi /opt/freeswitch/etc/freeswitch/autoload_configs
在150行处,定义随机打开端口范围31768~32768
注:如修改完启动freeswitch时只能启动8081/8082/8021端口,shutdonw后删除/opt/freeswitch/var/log/freeswitch/目录下的root权限文件和目录重启即可。
十二、启动freeswitch
# /usr/bin/freeswitch -nc -nonat
# netstat -lntup
tcp 0 0 0.0.0.0:8021 0.0.0.0:* LISTEN 28569/freeswitch
tcp 0 0 192.168.0.102:5080 0.0.0.0:* LISTEN 30917/freeswitch
tcp 0 0 192.168.0.102:5060 0.0.0.0:* LISTEN 30917/freeswitch
tcp 0 0 192.168.0.102:5066 0.0.0.0:* LISTEN 30917/freeswitch
tcp 0 0 192.168.0.102:8081 0.0.0.0:* LISTEN 30917/freeswitch
tcp 0 0 192.168.0.102:8082 0.0.0.0:* LISTEN 30917/freeswitch
tcp 0 0 192.168.0.102:7443 0.0.0.0:* LISTEN 30917/freeswitch
udp 0 0 192.168.0.102:5060 0.0.0.0:* 30917/freeswitch
udp 0 0 192.168.0.102:5080 0.0.0.0:* 30917/freeswitch
udp 0 0 0.0.0.0:1337 0.0.0.0:* 30917/freeswitch
# fs_cli //使用客户端连接程序连接freeswitch
十三、使用容器化部署
1.创建外挂log日志目录
mkdir /opt/freeswitch
2.启动容器
docker run -it --name freeswitch --restart=always --privileged=true --net=host -v /opt/freeswitch:/opt/freeswitch/var/log/freeswitch -d freeswitch:1.10.2
3.启动freeswitch
docker exec -it freeswitch bash -c 'freeswitch -nc -nonat'