一、添加第三方源
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
# 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
# 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 <<EOF [MySQL] Description = ODBC for MySQL Driver = /usr/lib/libmyodbc8a.so Setup = /usr/lib/libodbcmyS.so Driver64 = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc8a.so Setup64 = /usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so FileUsage = 1 EOF # cat > /etc/odbc.ini <<EOF [freeswitch] DRIVER = MySQL SERVER = 192.168.1.1 //mysql server ip PORT = 3306 DATABASE = fs_core //mysql freeswitch database USER = freesw //mysql freeswitch freesw database username PASSWORD = freesw@123 //mysql freeswitch freesw database passwd OPTION = 3 EOF # isql -v freeswitch //mysql測試連接性 # vi /opt/freeswitch/etc/freeswitch/autoload_configs/event_socket.conf.xml <param name="listen-ip" value="::"/> 改為 <param name="listen-ip" value="0.0.0.0"/>
十一、修改RTP語音通話UDP端口范圍
# vi /opt/freeswitch/etc/freeswitch/autoload_configs 在150行處,定義隨機打開端口范圍31768~32768 <!-- RTP port range --> <param name="rtp-start-port" value="31768"/> <param name="rtp-end-port" value="32768"/> <param name="rtp-enable-zrtp" value="true"/>
注:如修改完啟動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'