一,软件及环境准备:
ubuntu版本18.04:https://releases.ubuntu.com/18.04.6/ubuntu-18.04.6-live-server-amd64.iso freeswitch 版本1.10.7:https://files.freeswitch.org/freeswitch-releases/freeswitch-1.10.7.-release.tar.gz spandsp包:https://codeload.github.com/freeswitch/spandsp/zip/refs/heads/master sofia-sip包:https://codeload.github.com/freeswitch/sofia-sip/tar.gz/refs/tags/v1.13.9 二,环境及软件下载后更改镜像源 为163 ubuntu souces源 : gedit /etc/apt/sources.list deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse 三,进入到环境安装依赖包: apt-get update apt-get install -y autoconf git libtool g++ zlib1g-dev libjpeg-dev libcurl4-openssl-dev libspeex-dev libldns-dev libedit-dev libssl-dev pkg-config yasm liblua50-dev libopus-dev libsndfile1-dev libpq-dev libreadline-dev lua5.2 lua5.2-doc liblua5.2-dev libtiff5 libtiff5-dev sudo apt-get install -y vim sudo apt-get install -y g++ sudo apt-get install -y zlib1g-dev sudo apt-get install -y libjpeg-dev sudo apt-get install -y libsqlite3-dev sudo apt-get install -y libcurl4-gnutls-dev sudo apt-get install -y libpcre3-dev sudo apt-get install -y libspeexdsp-dev sudo apt-get install -y libedit-dev sudo apt-get install -y libssl-dev sudo apt-get install -y libopus-dev sudo apt-get install -y liblua5.2-dev sudo apt-get install -y libldns-dev sudo apt-get install -y libsndfile1-dev sudo apt-get install python3-pip sudo apt-get install unixodbc unixodbc-dev sudo apt-get install python3-pip sudo apt install libavformat-dev sudo apt install libswscale-dev 四:安装spandsp/sofia-sip:(安装freeswitch 前安装好) 1,安装sofia-sip: git cloen https://github.com/freeswitch/sofia-sip.git 如果网络不太好,git可能下载不下来,可以直接下载sofia-sip的zip压缩包 cd sofia-sip ./bootstrap.sh ./configure make make install 2,安装spandsp: git clone https://github.com/freeswitch/spandsp 如果网络不太好,git可能下载不下来,可以直接下载spandsp的zip压缩包 cd spandsp ./bootstrap.sh ./configure make make install ============= 五 安装freeswitch 1,进入到安装目录: cd /usr/local/freeswitch-1.10.7.-release./configure -C --enable-core-odbc-support
make
make install
六 配置freeswitch任何路径启动 #将freeswitch作符号软链接 ln -sf /usr/local/freeswitch/bin/freeswitch /usr/bin/ #fs_cli作符号软链接 ln -sf /usr/local/freeswitch/bin/fs_cli /usr/bin/ 七 相应配置文件更改1,阿里云不支持ipv6,做处理
vi /usr/local/freeswitch/conf/autoload_configs/event_socket.conf.xml<param name="listen-ip" value="::"/>修改为
<param name="listen-ip" value="127.0.0.1"/>
对相应IPv6文件做处理
ls /usr/local/freeswitch/conf/sip_profiles/internal-ipv6.xml
ls /usr/local/freeswitch/conf/sip_profiles/external-ipv6.xml
ls /usr/local/freeswitch/conf/sip_profiles/external-ipv6
cp /usr/local/freeswitch/conf/sip_profiles/internal-ipv6.xml /usr/local/freeswitch/conf/sip_profiles/internal-ipv6.xml_bak
cp /usr/local/freeswitch/conf/sip_profiles/external-ipv6.xml /usr/local/freeswitch/conf/sip_profiles/external-ipv6.xml_bak
cp /usr/local/freeswitch/conf/sip_profiles/external-ipv6 /usr/local/freeswitch/conf/sip_profiles/external-ipv6_bak -ra
2,为了安全修改SIP默认端口和分机默认密码
vi /usr/local/freeswitch/conf/vars.xml
<X-PRE-PROCESS cmd="set" data="default_password=1234"/>
修改成其他随机端口
<X-PRE-PROCESS cmd="set" data="internal_sip_port=5060"/>
<X-PRE-PROCESS cmd="set" data="external_sip_port=5080"/>
请根据自己情况修改编码
<X-PRE-PROCESS cmd="set" data="global_codec_prefs=OPUS,G722,PCMU,PCMA,VP8"/>
<X-PRE-PROCESS cmd="set" data="outbound_codec_prefs=OPUS,G722,PCMU,PCMA,VP8"/>
OPUS G722 VP8删除了,修为
<X-PRE-PROCESS cmd="set" data="global_codec_prefs=PCMU,PCMA"/>
<X-PRE-PROCESS cmd="set" data="outbound_codec_prefs=PCMU,PCMA"/>
阿里云专有网络,请设置为公网IP
<X-PRE-PROCESS cmd="set" data="external_sip_ip=阿里云公网IP"/>
<X-PRE-PROCESS cmd="set" data="external_rtp_ip=阿里云公网IP"/>
3,/usr/local/freeswitch/conf/sip_profiles/external.xml
<param name="ext-rtp-ip" value="auto-nat"/>
<param name="ext-sip-ip" value="auto-nat"/>
修改为
<param name="ext-rtp-ip" value="$${external_rtp_ip}"/>
<param name="ext-sip-ip" value="$${external_sip_ip}"/>
![](/i/l/?n=22&i=blog/853519/202209/853519-20220926162059639-138826828.png)
4,/usr/local/freeswitch/conf/sip_profiles/internal.xml
<param name="ext-rtp-ip" value="auto-nat"/>
<param name="ext-sip-ip" value="auto-nat"/>
修改为
<param name="ext-rtp-ip" value="$${external_rtp_ip}"/>
<param name="ext-sip-ip" value="$${external_sip_ip}"/>
![](/i/l/?n=22&i=blog/853519/202209/853519-20220926162229157-407557189.png)
5,修改配置文件4--打开NAT支持
/usr/local/freeswitch/conf/sip_profiles/external.xml
and
/usr/local/freeswitch/conf/sip_profiles/internal.xml
找到下面内容,去除注释,如果找不到自己添加
<param name="aggressive-nat-detection" value="true"/>
<param name="NDLB-force-rport" value="true"/>
vi /usr/local/freeswitch/conf/sip_profiles/external.xml
![](/i/l/?n=22&i=blog/853519/202209/853519-20220926162618225-891316036.png)
vi /usr/local/freeswitch/conf/sip_profiles/internal.xml
![](/i/l/?n=22&i=blog/853519/202209/853519-20220926162842400-1868506372.png)
6,以上配置 都是在 public里面,这个是任意Ip都可以呼入的,请在业务通过flow和calleeid字段控制一下,防止非法呼入。
也可以直接配置ACL,只有指定的IP才可以呼入。(如下配置ACL)
/usr/local/freeswitch/conf/sip_profiles/external.xml
在这句 <param name="local-network-acl" value="localnet.auto"/>
这之后加入 <param name="apply-inbound-acl" value="callin"/>
![](/i/l/?n=22&i=blog/853519/202209/853519-20220926163310270-77147249.png)
7,cat /usr/local/freeswitch/conf/autoload_configs/acl.conf.xml
加入
<list name="callin" default="deny">
<!--
<node type="allow" cidr="可以呼入的IP1/32"/>
<node type="allow" cidr="可以呼入的IP3/32"/>
<node type="allow" cidr="0.0.0.0/0"/> 这个写法就是允许任意IP
-->
</list>
这之前加入
</network-lists>
</configuration>
![](/i/l/?n=22&i=blog/853519/202209/853519-20220926164034929-912721921.png)
8,大并发优化
df
tmpfs 977004 0 977004 0% /dev/shm
看到这个就是创建了
1)修改配置文件1:usr/local/freeswitch/conf/autoload_configs/switch.conf.xml
<param name="max-sessions" value="20000"/>
<param name="sessions-per-second" value="2000"/>
<param name="core-db-name" value="/dev/shm/core.db" />
2)修改配置文件2:/usr/local/freeswitch/conf/sip_profiles/internal.xml
<!--<param name="dbname" value="share_presence"/>-->
修改为
<param name="dbname" value="/dev/shm/sofia_reg_internal.db"/>
3)修改配置文件3:/usr/local/freeswitch/conf/sip_profiles/external.xml
<!--<param name="dbname" value="share_presence"/>-->
修改为
<param name="dbname" value="/dev/shm/sofia_reg_external.db"/>
八 freeswitch 命令操作
===============启动命令================ #详细启动日志并进入控制台模式命令 freeswitch -c -nonat -rp #退出详细模式启动命令 shutdown #后台启动freeswitch服务(推荐使用) freeswitch -nc -nonat #进入控制台模式命令 fs_cli #退出控制台命令 /exit #关闭freeswitch命令 freeswitch -stop ===============查询服务命令============= #查看freeswitch安装路径 whereis freeswitch 查看进程号 ps -ef | grep freeswithch 查看freeswitch端口是否被监听 netstat -anp | grep 5060 #查看freeswitch的运行状态 status(控制台模式执行) #查看freewitch内置用户是否注册 sofia status profile internal reg(控制台模式执行) 九,启动,进入控制台![](/i/l/?n=22&i=blog/853519/202209/853519-20220926141309457-1966523080.png)
十,安装freeswitch 可能遇到的问题 见freeswitch常见问题
十一,Linux下Mysql_odbc的安装配置odbc
1,安装方式1:apt-get install libmyodbc 2,有的系统安装不了 libmyodbc只能直接安装 cd /usr/local/ 下载对应系统ubuntu18.04 对应版本 wget https://cdn.mysql.com//Downloads/Connector-ODBC/8.0/mysql-connector-odbc_8.0.30-1ubuntu18.04_amd64.deb wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-community-client-plugins_8.0.30-1ubuntu18.04_amd64.deb 进行安装 dpkg -i mysql-community-client-plugins_8.0.30-1ubuntu18.04_amd64.deb dpkg -i mysql-connector-odbc_8.0.30-1ubuntu18.04_amd64.deb![](/i/l/?n=22&i=blog/853519/202209/853519-20220926155218344-358477308.png)
4,安装数据库,同时创建数据库autodialer
CREATE DATABASE autodialer DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
5,执行如下命令:
myodbc-installer -d -a -n "MYSQL" -t "DRIVER=/usr/lib/x86_64-linux-gnu/odbc/libmyodbc8a.so;SETUP=/usr/lib/x86_64-linux-gnu/odbc/libmyodbc8a.so"
成功如下图![](/i/l/?n=22&i=blog/853519/202209/853519-20220926155826373-391587598.png)
6,最后执行:isql -v autodialer
成功显示:到这里有关mysql-odbc的安装配置终于完成
标签:sip,安装,dev,usr,conf,ubuntu,freeswitch,local From: https://www.cnblogs.com/kn-zheng/p/17373954.html