在Ubuntu 20.04/18.04/16.04和Debian 10/9上安装Asterisk 16 LTS

时间:2020-02-23 14:32:43  来源:igfitidea点击:

你好,好人!在本文中,我们将介绍在Ubuntu 20.04/18.04/16.04和Debian 10/Debian 9上安装Asterisk 16 LTS的步骤.Asterisk是一个开源完整的PBX系统,具有大多数商业上可用的PBX系统。
它支持会议电话,直接向内系统访问,呼叫停车,呼叫队列以及许多其他函数。

在Ubuntu 18.04/16.04和Debian 10/9上安装Asterisk 16

以下是在Ubuntu 20.04/18.04/16.04和Debian 10/9上安装Asterisk 16的步骤。

第1步:更新系统

通过更新系统开始在Ubuntu 20.04/18.04/16.04和Debian 10/9上安装Asterisk 16的安装以避免任何依赖性问题:

sudo apt update && sudo apt -y upgrade
sudo reboot

第2步:安装Asterisk 16 LTS依赖项

系统启动并更新后,安装所有必需的星号依赖项包:

sudo apt -y install git curl wget libnewt-dev libssl-dev libncurses5-dev subversion  libsqlite3-dev build-essential libjansson-dev libxml2-dev  uuid-dev

如果我们在下面的Ubuntu上获得Subversion包的错误:

E: Package 'subversion' has no installation candidate

然后添加Universe存储库并从中安装Subversion:

sudo add-apt-repository universe
sudo apt update && sudo apt -y install subversion

第3步:下载Asterisk 16 LTS tar包

由于Debian和Ubuntu上游存储库中没有Asterisk 16,因此安装将从源代码完成。
从源代码构建使我们可以轻松构建我们想要的所有PBX函数,并具有自定义VoIP系统。

$sudo apt policy asterisk
asterisk:
  Installed: (none)
  Candidate: 1:13.14.1~dfsg-2+deb9u3
  Version table:
     1:13.14.1~dfsg-2+deb9u3 500
...
$sudo apt policy asterisk
asterisk:
  Installed: (none)
  Candidate: 1:13.18.3~dfsg-1ubuntu4

下载最新版本的Asterisk 16 LTS到本地安装。

cd /usr/src/
sudo curl -O http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-16-current.tar.gz

然后提取文件:

sudo tar xvf asterisk-16-current.tar.gz
cd asterisk-16*/

运行以下命令将MP3解码库库下载到源树中。

$sudo contrib/scripts/get_mp3_source.sh
A addons/mp3/decode_ntom.c
A addons/mp3/interface.c
A addons/mp3/MPGLIB_README
A addons/mp3/common.c
A addons/mp3/huffman.h
A addons/mp3/tabinit.c
A addons/mp3/Makefile
A addons/mp3/README
A addons/mp3/decode_i386.c
A addons/mp3/dct64_i386.c
A addons/mp3/MPGLIB_TODO
A addons/mp3/mpg123.h
A addons/mp3/layer3.c
A addons/mp3/mpglib.h
Exported revision 202.

确保解决所有依赖项:

sudo contrib/scripts/install_prereq install

我们应该在最后获得成功消息:

#############################################
## install completed successfully
#############################################

第4步:在Ubuntu 20.04/18.04/16.04和Debian 10/9上构建和安装Asterisk 16

一旦我们下载了Asterisk 16 tar包并安装所需的依赖项,我们应该准备好构建星号。

运行配置脚本以满足构建依赖项。

sudo ./configure

成功应具有如下所示的

..................
configure: Menuselect build configuration successfully completed
               .$$$$$$$$=..      
            ...          .7:.    
          .$:.                 ,.7   
        ..     7$$          .  
     ..$.       $$$           .$ 
    ..7$  .?.   $$$  .?.       7$$.
   $.$.   .$. $ .7$$.      .$$.
 .777.   .$$$$$.      $$,
 $$~      .7$$$$$$.       .$$.
.          .7$$$:          ?$$.
$$         ?7$$$$$I        .$ 
$$      .7$$$$$$$$     :$$. 
$$      $$$$$$$$   .$$.  
$$       $$  7$  .$$   .$$.   
$$            $         .$$.    
7$            7$$       7$$     
 $$$                       $$      
  $.                       $ (TM)     
   $$$$.           .7$$$ $     
     $$$$$$$$$$.$$$     
       $$$$$$$$.                
configure: Package configured for: 
configure: OS type  : linux-gnu
configure: Host CPU : x86_64
configure: build-cpu:vendor:os: x86_64 : pc : linux-gnu :
configure: host-cpu:vendor:os: x86_64 : pc : linux-gnu :

通过运行以下命令设置菜单选项:

sudo make menuselect

使用箭头键导航,然后输入键以选择。

在添加组件上选择 chan_ooh323format_mp3如下所示

在核心声音包上,选择如下所示的音频数据包格式

有关音乐,请选择以下最小模块

在额外的声音包中选择如下所示:

使能够 app_macro在Applications菜单下。

我们可以更改我们认为适合的其他配置。
完成后,保存和退出然后使用所选模块安装Asterisk。

然后通过运行构建星号:

sudo make

示例

Building Documentation For: third-party channels pbx apps codecs formats cdr cel bridges funcs tests main res addons 
 +--------- Asterisk Build Complete ---------+
 + Asterisk has successfully been built, and +
 + can be installed by running:              +
 +                                           +
 +                make install               +

完成后,通过运行命令来安装Asterisk:

sudo make install

示例

+---- Asterisk Installation Complete -------+
 +                                           +
 +    YOU MUST READ THE SECURITY DOCUMENT    +
 +                                           +
 + Asterisk has successfully been installed. +
 + If you would like to install the sample   +
 + configuration files (overwriting any      +
 + existing config files), run:              +
 +                                           +
 + For generic reference documentation:      +
 +    make samples                           +
 +                                           +
 + For a sample basic PBX:                   +
 +    make basic-pbx                         +
 +                                           +
 +                                           +
 +-----------------  or ---------------------+
 +                                           +
 + You can go ahead and install the asterisk +
 + program documentation now or later run:   +
 +                                           +
 +               make progdocs               +
 +                                           +
 + **Note** This requires that you have      +
 + doxygen installed on your local system    +
 +-------------------------------------------+

我们可以选择安装文档:

sudo make progdocs

最后,安装Configs和Samples。

sudo make samples
sudo make config
sudo ldconfig

将创建Asterisk的SystemD服务单元文件。

创建Asterisk用户

创建单独的用户和组以运行Asterisk服务,并分配正确的权限:

sudo groupadd asterisk
sudo useradd -r -d /var/lib/asterisk -g asterisk asterisk
sudo usermod -aG audio,dialout asterisk
sudo chown -R asterisk.asterisk /etc/asterisk
sudo chown -R asterisk.asterisk /var/{lib,log,spool}/asterisk
sudo chown -R asterisk.asterisk /usr/lib/asterisk

将Asterisk默认用户设置为星号:

$sudo vim /etc/default/asterisk
AST_USER="asterisk"
AST_GROUP="asterisk"
$sudo vim /etc/asterisk/asterisk.conf
runuser = asterisk ; The user to run as.
rungroup = asterisk ; The group to run as.

进行更改后重新启动Asterisk服务:

sudo systemctl restart asterisk

启用Asterisk服务以启动系统引导:

sudo systemctl enable asterisk

服务应该运行而没有错误:

$systemctl status asterisk
● asterisk.service - LSB: Asterisk PBX
     Loaded: loaded (/etc/init.d/asterisk; generated)
     Active: active (running) since Sun 2017-05-03 12:18:29 UTC; 1min 19s ago
       Docs: man:systemd-sysv-generator(8)
      Tasks: 69 (limit: 2344)
     Memory: 112.0M
     CGroup: /system.slice/asterisk.service
             └─88786 /usr/sbin/asterisk -U asterisk -G asterisk
Jan 03 12:18:29 ubuntu20 systemd[1]: Starting LSB: Asterisk PBX...
Jan 03 12:18:29 ubuntu20 asterisk[88756]:  * Starting Asterisk PBX: asterisk
Jan 03 12:18:29 ubuntu20 asterisk[88756]:    ...done.
Jan 03 12:18:29 ubuntu20 systemd[1]: Started LSB: Asterisk PBX.

测试查看我们是否可以连接到Asterisk CLI:

$sudo asterisk -rvv
Asterisk 16.10.0, Copyright (C) 1999 - 2016, Digium, Inc. and others.
Created by Mark Spencer <Hyman@theitroad>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Running as user 'asterisk'
Running under group 'asterisk'
Connected to Asterisk 16.10.0 currently running on ubuntu20 (pid = 88786)
ubuntu-01*CLI> core  show channels
Channel              Location             State   Application(Data)             
0 active channels
0 active calls
0 calls processed
ubuntu-01*CLI> exit
Asterisk cleanly ending (0).
Executing last minute cleanups

如果我们有一个Active UFW防火墙,请打开HTTP端口和端口5060,5061:

sudo ufw allow proto tcp from any to any port 5060,5061