最も完全な FreeSwitch 1.10.9 Linux の一般的なコンパイルと展開のチュートリアル

FreeSwitch ユニバーサル コンパイルと展開のチュートリアル


FreeSwitch のバージョン履歴

2006 - 最初のバージョン
2008 - Phoenix バージョン 1.0
2012 - FreeSwitch 1.2
2014 - FreeSwitch 1.4 WebRTC
2015 - FreeSwitch 1.6 ビデオ通話およびビデオ会議
2017 - FreeSwitch 1.8
2019 - FreeSwitch 1.10
2020 - FreeSwitch 1.10.3
2023 - FreeSwitch 1。 10.9

このインストールチュートリアルは、freeswitch1.10.2 および freeswitch1.10.9 バージョンが正常にインストールできることをセルフテストします。freeswitch1.10.7/freeswitch1.10.8 のインストール状況は freeswitch1.10.9 と同じである必要があります。

1. 基本環境

オペレーティング システム:
Alibaba Cloud ECS CentOS Linux リリース 7.9 (Ubuntu などの Linux システムでのインストールの問題については記事の最後を参照してください。基本的に同じである前の手順を参照してください)


cat /proc/version または uname -a コマンドを実行して、Linux バージョン 3.10.0-1160.90.1.el7.x86_64 ([email protected]) (gcc バージョン 4.8.5 20150623 (Red Hat 4.8.5) を表示します。-44 ) (GCC) )

2.設置方法

ソースコードを使用してコンパイルおよびインストールする

git を使用してコードを取得し、コンパイルしてインストールすることも、WinSCP などのツールを使用してソース コード tar パッケージをサーバーにアップロードしてコンパイルしてインストールすることもできます。

3. 基本的な依存関係をインストールする

yum install -y git alsa-lib-devel autoconf automake bison broadvoice-devel bzip2 curl-devel libdb4-devel e2fsprogs-devel erlang flite-devel g722_1-devel gcc-c++ gdbm-devel gnutls-devel ilbc2-devel ldns-devel libcodec2-devel libcurl-devel libedit-devel libidn-devel libjpeg-devel libmemcached-devel libogg-devel libsilk-devel libsndfile-devel libtheora-devel libtiff-devel libtool libuuid-devel libvorbis-devel libxml2-devel lua-devel lzo-devel mongo-c-driver-devel ncurses-devel net-snmp-devel openssl-devel opus-devel pcre-devel perl perl-ExtUtils-Embed pkgconfig portaudio-devel postgresql-devel python-devel python-devel soundtouch-devel speex-devel sqlite-devel unbound-devel unixODBC-devel wget which yasm zlib-devel libshout-devel libmpg123-devel lame-devel

4.cmakeをダウンロードし、コンパイルしてインストールします。

wget https://github.com/Kitware/CMake/releases/download/v3.23.0/cmake-3.23.0.tar.gz
tar -zvxf cmake-3.23.0.tar.gz
cd cmake-3.23.0
./bootstrap
make
make install

#链接
sudo ln -sf /usr/local/bin/cmake /usr/bin/cmake
sudo ln -sf /usr/local/bin/cpack /usr/bin/cpack
sudo ln -sf /usr/local/bin/ctest /usr/bin/ctest

5. 必要な依存関係を手動でインストールする必要があります

autoconf-2.71 以降の
ダウンロード リンク: http://mirrors.kernel.org/gnu/autoconf/

cd /usr/local/src
tar xzvf autoconf-2.71.tar.gz
cd autoconf-2.71
./configure  //做相关编译前的环境检查
make
make install

opus-1.3.1以降

yum remove opus
cd /usr/local/src
wget https://archive.mozilla.org/pub/opus/opus-1.3.1.tar.gz
tar xzvf opus-1.3.1.tar.gz
cd opus-1.3.1
./configure  //做相关编译前的环境检查
make
make install
cp /usr/lib/pkgconfig/opus.* /usr/lib64/pkgconfig/

opus がインストールされていない場合、コンパイル時にエラーが報告されます。
You must install libopus-dev to build mod_opus. Stop.
手動インストールしても動作しない場合は、次のようにインストールしてください。

cd /etc/yum.repos.d/
touch linuxtech.repo
vi  linuxtech.repo

//linuxtech.repo中添加如下内容:
//按i或者insert键进入编辑模式,按Esc键退出编辑模式,输入:wq!保存退出。

[linuxtech]
name=LinuxTECH
baseurl=http://pkgrepo.linuxtech.net/el6/release/
enabled=1
gpgcheck=1
gpgkey=http://pkgrepo.linuxtech.net/el6/release/RPM-GPG-KEY-LinuxTECH.NET

//最后安装opus:
yum install libopus-devel

6. ソースコードをダウンロードする

freeswitch1.10.4 以降のバージョンでは、freeswitch は正式に spandsp と sofia-sip を分離します。コードを別途コンパイルする必要があります。freeswitch 1.10.4 より前 (freeswitch1.10.2 バージョンなど) をコンパイルしている場合は、別途 pull する必要はありませんspandsp と sofia-sip. コードは、freeswitch を直接コンパイルするだけです

重大改动历史:
https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Release-Notes/FreeSWITCH-1.10.x-Release-notes_25460878/

//可直接在上述链接中下载freeswitch的tar包

1.8 -> 1.10.0: pgqsql moved out from FreeSWITCH core to its own module, mod_pgsql .
See 1.10.0 (Release date: 05 August 2019) at the bottom.
1.10.3 -> 1.10.4: SpanDSP and sofia-sip have been removed.
See 1.10.4 (Release date: 05 Aug 2020)​ below.
1.10.6 -> 1.10.7: Default behaviour change: to not skip announcement type apps on recovery, not hangup call on SRTP errors, 1000 maximum receiving requests per second, auth-messages and auth-subscriptions are enabled by default now, freeswitch.log log line prefix modified: will affect fail2ban log line matching until similarly modified in fail2ban (https://github.com/fail2ban/fail2ban/issues/3143).
See 1.10.7 (Release date: 24 Oct 2021)​ below.
//如果安装freeswitch1.10.2等版本可以不用拉spandsp和sofia-sip的代码,直接在官网链接下载tar包导入服务器即可解压编译

cd /usr/local/src
git clone -b v1.10.9 https://github.com/signalwire/freeswitch

cd /usr/local/src/freeswitch
git clone https://github.com/freeswitch/spandsp.git
git clone https://github.com/freeswitch/sofia-sip.git
//编译spandsp
cd /usr/local/src/freeswitch/spandsp
./bootstrap.sh
./configure
make
make install
//编译sofia-sip
cd /usr/local/src/freeswitch/sofia-sip
./bootstrap.sh
./configure
make
make install
//添加库的路径到系统
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH} 
ldconfig

freeswitch をコンパイルする前に、不要なモジュールのコンパイルを無効にしてください。そうでない場合は、対応する依存関係をインストールする必要があります。そうしないと、エラーが報告されます。

cd /usr/local/src/freeswitch
vim module.conf

//将mod_signalwire和mod_av内容注释掉

#applications/mod_signalwire
#applications/mod_av

//mod_verto不禁用可能会编译报错You need to either install libks or disable mod_verto in modules.conf

#endpoints/mod_verto  
//编译freeswitch
cd /usr/local/src/freeswitch
./bootstrap.sh  //如果是GitHub拉的代码有这一步,如果是下载tar包解压的没有这一步
./configure --enable-portable-binary --prefix=/usr/local/freeswitch --with-gnu-ld --with-python --with-openssl --enable-core-odbc-support --enable-zrtp
make
make install

コンパイル中に spandsp がインストールされていないことを示すメッセージが表示される場合は、対応するフォルダーに戻ってmake installspandsp をスキャンします。

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH} 
ldconfig

もう一度戻ってmake clean、設定し直して./configure、もう一度試してくださいmake

7. freeswitch1.10.9 の問題処理をコンパイルする

以前の依存関係をインストールした後、freeswitch 1.10.9 をコンパイルするときに依存関係エラーが報告されることはありません (依存関係エラーがある場合は、欠落している手順がないか確認してください。そうしないと、Baidu で解決できます。必ずクリーンにしてから再実行してください。/ spandsp 関連コンテンツのコンパイル時にエラーが発生しました: 'V18_MODE_5BIT_4545' が宣言されていません:

making all mod_spandsp
make[4]: Entering directory `/usr/local/src/freeswitch-1.10.9.-release/src/mod/applications/mod_spandsp'
  CC       mod_spandsp_la-mod_spandsp.lo
  CC       mod_spandsp_la-udptl.lo
  CC       mod_spandsp_la-mod_spandsp_fax.lo
  CC       mod_spandsp_la-mod_spandsp_dsp.lo
mod_spandsp_dsp.c: In function ‘get_v18_mode’:
mod_spandsp_dsp.c:159:10: error: ‘V18_MODE_5BIT_4545’ undeclared (first use in this function)
  int r = V18_MODE_5BIT_4545;
          ^
mod_spandsp_dsp.c:159:10: note: each undeclared identifier is reported only once for each function it appears in
mod_spandsp_dsp.c:165:8: error: ‘V18_MODE_5BIT_50’ undeclared (first use in this function)
    r = V18_MODE_5BIT_50;
        ^
mod_spandsp_dsp.c: In function ‘spandsp_tdd_send_session’:
mod_spandsp_dsp.c:216:2: error: too few arguments to function ‘v18_init’
  tdd_state = v18_init(NULL, TRUE, get_v18_mode(session), V18_AUTOMODING_GLOBAL, put_text_msg, NULL);
  ^
In file included from /usr/local/include/spandsp.h:111:0,
                 from mod_spandsp.h:50,
                 from mod_spandsp_dsp.c:36:
/usr/local/include/spandsp/v18.h:138:29: note: declared here
 SPAN_DECLARE(v18_state_t *) v18_init(v18_state_t *s,
                             ^
mod_spandsp_dsp.c: In function ‘spandsp_tdd_encode_session’:
mod_spandsp_dsp.c:263:2: error: too few arguments to function ‘v18_init’
  pvt->tdd_state = v18_init(NULL, TRUE, get_v18_mode(session), V18_AUTOMODING_GLOBAL, put_text_msg, NULL);
  ^
In file included from /usr/local/include/spandsp.h:111:0,
                 from mod_spandsp.h:50,
                 from mod_spandsp_dsp.c:36:
/usr/local/include/spandsp/v18.h:138:29: note: declared here
 SPAN_DECLARE(v18_state_t *) v18_init(v18_state_t *s,
                             ^
mod_spandsp_dsp.c: In function ‘spandsp_tdd_decode_session’:
mod_spandsp_dsp.c:341:2: error: too few arguments to function ‘v18_init’
  pvt->tdd_state = v18_init(NULL, FALSE, get_v18_mode(session), V18_AUTOMODING_GLOBAL, put_text_msg, pvt);
  ^
In file included from /usr/local/include/spandsp.h:111:0,
                 from mod_spandsp.h:50,
                 from mod_spandsp_dsp.c:36:
/usr/local/include/spandsp/v18.h:138:29: note: declared here
 SPAN_DECLARE(v18_state_t *) v18_init(v18_state_t *s,
                             ^
make[4]: *** [mod_spandsp_la-mod_spandsp_dsp.lo] Error 1
make[4]: Leaving directory `/usr/local/src/freeswitch-1.10.9.-release/src/mod/applications/mod_spandsp'
make[3]: *** [mod_spandsp-all] Error 1
make[3]: Leaving directory `/usr/local/src/freeswitch-1.10.9.-release/src/mod'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/usr/local/src/freeswitch-1.10.9.-release/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/src/freeswitch-1.10.9.-release'
make: *** [all] Error 2
[root@maomaosPC freeswitch-1.10.9.-release]# 

ソース コードを Source Insight プロジェクトに配置し、関連するキーワードを検索します。検査の結果、コンパイル エラーは spandsp のコンテンツが原因であることが判明しました。freeswitch に関連するコードが spandsp モジュール コードと一致しません。GitHub にアクセスして送信内容を確認してください。記録です。それはたまたま 6 月 23 日の終わりでした。私が編集する数日前に提出されました。なんて不運な男でしょう。さらに言えば、現時点では、spandsp コードを以前のコードと一致するバージョンにロールバックし、それを再コンパイルして正常にコンパイルできるようにすることを検討してください。
具体的な手順:

//先切到对应目录下删除相关内容
cd /usr/local/src/freeswitch
rm -rf spandsp
//重新拉取代码
git clone https://github.com/freeswitch/spandsp.git
//spandsp目录下执行git log或者gitlab上查看对应commit id并切换
git checkout -b finecode20230705 0d2e6ac65e0e8f53d652665a743015a88bf048d4
//按照之前的步骤重新编译安装
//在Github上反馈了这个问题后, 维护人员2023/07/19回复:
mod_spandsp uses the defines you change, e.g. V18_MODE_5BIT_4545 from v18.h,
so it is broken now as it hasn't been updated.It needs to be updated with new defines.

freeswitch をインストールした後、任意のディレクトリで freeswitch を実行できるようにするために、ソフト接続を構成できます。

ln -sf /usr/local/freeswitch/bin/freeswitch /usr/local/bin/
ln -sf /usr/local/freeswitch/bin/fs_cli /usr/local/bin/
//freeswitch默认安装路径/usr/local/freeswitch

8. 共通設定ファイルの説明

書類 説明する
vars.xml よく使用される変数のいくつか
ダイヤルプラン/default.xml デフォルトのダイヤルプラン
ディレクトリ/デフォルト/*.xml SIP ユーザー、ユーザーごとに 1 つのファイル
sip_profiles/internal.xml 一口
sip_profiles/externa.xml 別の SIP-UA、外部接続として使用、ポート 5080
autoload_configs/modules.conf.xml FreeSWITCH の起動時にどのモジュールが自動的にロードされるかを設定します

デフォルトのポートを変更します: (freeswitch1.10.9 は /usr/local/freeswitch/etc/freeswitch ディレクトリ
cd /usr/local/freeswitch/conf
あります)
vars.xml を見つけて変更します: (コピーをコピーして、vars.xml.bak バックアップとして保存できます)
デフォルトのポート
<X-PRE-PROCESS cmd="set" data="internal_sip_port=5060"/>
5060。デフォルトは freshwitch SIP シグナリング内部ポートです。

9. ファイアウォールの設定

1. var.xml を修正します。
<!--X-PRE-PROCESS cmd="stun-set" data="external_rtp_ip=stun:stun.freeswitch.org"/-->ここでは stun 機能は使用せず、パブリック ネットワーク IP を直接入力します
<X-PRE-PROCESS cmd="stun-set" data="external_rtp_ip="阿里云分配的公网ip"/>
(freeswitch1.10.9 は、設定せずにデフォルトのポートであれば正常に使用されるようです。xml を修正した後)ファイルにアクセスできないため、設定する必要があります。スタンにしてから xml をリロードします)

var.xml を変更した後は、conf/sip_profiles/internal.xml と external.xml を変更する必要はありません。これら 2 つのファイルを実際に使用せずに直接変更する例がインターネット上に多数あります。これら 2 つのファイルは var で作成されており、external_rtp_ip 変数を直接参照できます。

2. Alibaba Cloud のファイアウォールとオペレーティング システムのファイアウォールを構成します。具体的な参照:
https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Networking/Firewall_1048908/

注:
Alibaba Cloud: [インスタンス] -> [セキュリティ グループ] -> [構成ルール] をクリックして、ファイアウォール ルールの構成を開始します。
さらに、クラウド サーバーのツールも Pagoda にインストールされている場合は、Pagoda パネルでファイアウォールを次のように設定する必要があります。フリースイッチが適切に動作できるようにします。

ファイアウォールの設定が完了したら、デバイス登録サーバーを使用してエコー番号 9196 にダイヤルし、エコーが聞こえるかどうかを確認します。

FreeSwitch で一般的に使用されるデフォルトの番号:
番号の説明
9664 音楽を保持する
9191 CluCon を登録する
9192 ログに表示する通話情報 チャネル情報
9195 エコー、エコー テスト、5 秒の遅延
9196 エコー、エコー テスト
9197 ミリワット拡張、着信音の生成
9198 TGML 着信音の生成例
9180 着信音テスト、リモート エンドによって生成された着信音を使用します。
9181 着信音テスト、英国の着信音を生成します。 9182 着信音テスト
、着信音として音楽を使用し、着信音に色を付けます
。 9183 最初に応答してから、英国の着信音を送信します
。 9184応答してから送信 音楽着信音
9178 FAX 受信
9179 FAX 送信
5000 IVR インスタンス
4000 アイデアメールボックスを聞く
33xx 電話会議、48Hz (xx は 00 ~ 99、以下同様)
32xx 電話会議、32Hz (xx は 00 ~ ) 99、以下同じ)
31xx 電話会議、16Hz(xx は 00 ~ 99、以下同じ)
30xx 電話会議、8Hz(xx は 00 ~ 99、以下同じ)
2000-2002 通話グループ
1000-1019 デフォルトの内線番号番号 (デフォルトのパスワード 1234)

FreeSwitch のデフォルト番号はほとんどがダイヤル プランの名前であり、特に conf/diaplan/default.xml で定義されています。

10. アカウントとパスワードの設定/新しいユーザーの追加

デフォルトのパスワードを変更します: vars.xml
<X-PRE-PROCESS cmd="set" data="default_password=1234"/>

ユーザーをバッチで freeswitch に追加します。
参考: https://blog.51cto.com/u_15049794/3833216
(freeswitch1.10.9 は /usr/local/freeswitch/etc/freeswitch ディレクトリにあります)
/usr/local/freeswitch/ conf/directory/ デフォルトには、これら 20 人のデフォルト ユーザー用の 1000.xml ~ 1019.xml 設定ファイルがあります。

ユーザーの XML を作成した後、これらの新しいユーザーの XML をロードするには、ファイル /usr/local/freeswitch/conf/dialplan/default.xml 内のダイヤル ルール (正規表現) を変更する必要があります。

<extension name="Local_Extension">
<!-- 这里可以修改正则范围,允许所有分机号-->
<!--默认为  <condition field="destination_number" expression="^(10[01][0-9])$">   -->
<condition field="destination_number" expression="^([0-9]\d+)$">
<!-- ... -->
<action application="set" data="call_timeout=120"/>
<!-- ... -->
</condition>
</extension>

主なことは、すべての数値を許可するように正規表現を変更することです。また、N 秒間着信がなかった場合にタイムアウトを考慮するデフォルト設定 (デフォルトは 30 秒) があり、調整が必要な場合は同時に変更することもできます。
/usr/local/freeswitch/conf/dialplan/public.xml を調整します。

<extension name="public_extensions">
   <!-- 允许所有分机号 -->
   <condition field="destination_number" expression="^([0-9]\d+)$">
       <action application="transfer" data="$1 XML default"/>
   </condition>
</extension>

ユーザー XML ファイルをバッチで生成します。

import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class CreateFreeswitchUser {
    
    

    public static void main(String[] args) throws IOException {
    
    
        String template = "D:\\soft\\FreeSWITCH\\conf\\directory\\default\\";
        String templateContent = read(template + "1000.xml");
        //创建99个用户
        for (int i = 1; i < 100; i++) {
    
    
            String newUser = "1" + StringUtils.leftPad(i + "", 3, '0');
            String newContent = templateContent.replaceAll("1000", newUser);
            String newFileName = template + newUser + ".xml";
            write(newFileName, newContent);
            System.out.println(newFileName + " done!");
        }
    }

    static String read(String fileName) throws IOException {
    
    
        File f = new File(fileName);
        if (!f.exists()) {
    
    
            return null;
        }
        FileInputStream fs = new FileInputStream(f);
        String result = null;
        byte[] b = new byte[fs.available()];
        fs.read(b);
        fs.close();
        result = new String(b);
        return result;
    }

    static void write(String fileName, String fileContent) throws IOException {
    
    
        File f = new File(fileName);
        if (f.exists()) {
    
    
            f.delete();
        }
        FileOutputStream fs = new FileOutputStream(f);
        fs.write(fileContent.getBytes());
        fs.flush();
        fs.close();
    }
}

次に、生成されたユーザー ファイルを /usr/local/freeswitch/conf/directory/default ディレクトリにコピーします。

11.freeswitch バックグラウンド基本操作手順

ps -ef | grep freeswithch 查看进程号
netstat -an | grep 5060 查询FreeSWITCH 监听在哪个IP地址上(默认5060端口的情况下)
whereis freeswitch 查看freeswitch安装路径


freeswitch -help可查看帮助信息
freeswitch  启动并前台运行
freeswitch -nc  启动并后台运行
freeswitch -stop 停止

fs_cli 进入freeswitch控制台后:
show registrations 查看注册用户情况
sofia status profile internal reg 显示在线注册用户信息
status 查看freeswitch的运行状态
/exit 或 /quit 或 /bye  退出fs_cli
shutdown 关闭freeswitch
reloadxml 重新加载xml配置
console loglevel 7 开启控制台日志级别, 0-7, 数字越大日志越多
version 显示版本信息

12. 関連する tar パッケージをダウンロードする

ネットワークが良好でなく、GitHub でコードをプルダウンできない場合は、次の tar パッケージをダウンロードしてコンパイルして試すことができます: (0 ポイント、CSDN 用の作業は一切行わない) 含まれているもの: autoconf-2.71、cmake-3.23。 0、opus-1.3.1. sofia-sip、spandsp、freeswitch-1.10.2.-release、freeswitch-1.10.9.-release
リンク:
https://download.csdn.net/download/qq_36369267/88003573

13. VoIP クライアント ツールの推奨事項:

portsip-uc と linphone をお勧めします。Android と Windows 用のインストール パッケージがあります。Portsip には IOS 用のクライアントもあります。自分で検索してダウンロードできます。

14.Ubuntuの問題:

手順は基本的に CentOS と同じですが、具体的な手順については、次のブログ投稿を参照してください:
https://blog.csdn.net/qq_40170041/article/details/123996904

コンパイルおよびデプロイ時に発生する可能性のある問題:

#报错1
configure: error: no usable libodbc; please install unixodbc devel package or equivalent
#处理
sudo apt-get install unixodbc
或./configure时不带参数(unixodbc安装后没用时采用此方式)
#报错2:
src/switch_apr.c:81:23: fatal error: uuid/uuid.h: No such file or directory
#处理
sudo apt-get install uuid-dev

15.参考:

参考文献:
https://www.cnblogs.com/kn-zheng/p/17388340.html
https://blog.51cto.com/lion3875/599416
http://www.360doc.com/content/15/0401/ 19/15077656_459884519.shtml

おすすめ

転載: blog.csdn.net/qq_36369267/article/details/131564019