如何在CentOS 8/Rhel 8上安装Asterisk 16 LTS

时间:2020-02-23 14:30:36  来源:igfitidea点击:

欢迎我们关于如何在CentOS 8/Rhel 8 Linux上安装Asterisk 16 LTS的教程。
Asterisk是一个流行且强大的开源PBX系统,具有类似于仅在商业PBX系统中发现的功能。
Asterisk在SMB和Enterprise Setup中提供IP PBX系统,VoIP网关,会议服务器和呼叫中心。

在CentOS/Rhel 8上安装Asterisk 16 LTS

在开始Asterisk安装之前:通过运行以下命令,在许可模式下设置Server.Set Selinux的时区:

sudo setenforce 0
sudo sed -i 's/\(^SELINUX=\).*/\SELINUX=permissive/' /etc/selinux/config

然后按照以下步骤安装和配置CentOS/RHEL 8服务器上的Asterisk 16 LTS。

第1步:添加epel存储库

通过以下导向下面,确保我们将Epel存储库添加到Rhel/CentOS 8系统中。

如何在Rhel/CentOS 8上安装Epel存储库

第2步:安装开发工具

安装软件开发工具和在RHEL/CentOS 8上运行Asterisk所需的其他依赖项。

sudo dnf group -y install "Development Tools"
dnf install git wget vim  net-tools sqlite-devel psmisc ncurses-devel libtermcap-devel newt-devel libxml2-devel libtiff-devel gtk2-devel libtool libuuid-devel subversion kernel-devel kernel-devel-$(uname -r) crontabs cronie-anacron

第3步:下载并安装Jansson

Jansson是用于编码,解码和操作JSON数据的C库。
通过运行下面的命令下载并在CentOS/RHEL 8服务器上安装:

cd /usr/src/
git clone https://github.com/akheron/jansson.git
cd jansson
autoreconf -i
./configure --prefix=/usr/
make && make install

第4步:下载并安装PJSIP

PJSIP是一种以C语言编写的自由和开源多媒体通信库,实现基于标准的协议,如SIP,SDP,RTP,STUN,TOW和ICE。

从GitHub克隆项目,然后编译和安装。

cd /usr/src/
git clone https://github.com/pjsip/pjproject.git
cd pjproject
./configure CFLAGS="-DNDEBUG -DPJ_HAS_IPV6=1" --prefix=/usr --libdir=/usr/lib64 --enable-shared --disable-video --disable-sound --disable-opencore-amr
make dep
make
make install
ldconfig

第5步:下载和安装星号

现在我们安装了所有依赖包,我们应该准备好下载并安装Centos/Rhel 8上的Asterisk 15.

cd /usr/src/
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-16-current.tar.gz
tar xvfz asterisk-16-current.tar.gz
rm -f asterisk-16-current.tar.gz
cd asterisk-16*/

安装libedit包。

sudo dnf -y install https://rpmfind.net/linux/fedora/linux/releases/29/Everything/x86_64/os/Packages/l/libedit-3.1-24.20160329cvs.fc29.x86_64.rpm
sudo dnf -y install https://rpmfind.net/linux/fedora/linux/releases/29/Everything/x86_64/os/Packages/l/libedit-devel-3.1-24.20160329cvs.fc29.x86_64.rpm

配置星号。

./configure --libdir=/usr/lib64

成功的配置应打印如下所示的输出。

.....
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 :

第6步:设置Asterisk菜单选项

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

make menuselect

使用箭头键导航,然后输入键以选择。 1.在添加组件下选择 chan_ooh323format_mp3如下所示

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

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

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

6.使能够 app_macro根据"应用程序"部分。

随意修改其他设置以满足需求,然后在完成后保存和退出。

第7步:构建和安装星号

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

sudo contrib/scripts/get_mp3_source.sh

在Rhel/CentOS 8上构建和安装Asterisk。

make
make install
make samples
make config
ldconfig

第8步:配置和启动星号

创建单独的用户和组以运行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 /var/{lib,log,spool}/asterisk /usr/lib64/asterisk

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

$sudo vim /etc/sysconfig/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

启用服务以启动启动:

sudo systemctl enable asterisk

确认服务状态。

$systemctl status asterisk
 ● asterisk.service - LSB: Asterisk PBX
    Loaded: loaded (/etc/rc.d/init.d/asterisk; generated)
    Active: active (running) since Sat 2019-03-23 14:31:11 EAT; 31s ago
      Docs: man:systemd-sysv-generator(8)
   Process: 13468 ExecStop=/etc/rc.d/init.d/asterisk stop (code=exited, status=0/SUCCESS)
   Process: 13494 ExecStart=/etc/rc.d/init.d/asterisk start (code=exited, status=0/SUCCESS)
  Main PID: 13525
     Tasks: 2 (limit: 11510)
    Memory: 3.1M
    CGroup: /system.slice/asterisk.service
            ├─13523 /bin/sh /usr/sbin/safe_asterisk
            └─13614 sleep 4
Mar 23 14:31:11 rhel8.local systemd[1]: Stopped LSB: Asterisk PBX.
Mar 23 14:31:11 rhel8.local systemd[1]: Starting LSB: Asterisk PBX…
Mar 23 14:31:11 rhel8.local systemd[1]: Started LSB: Asterisk PBX.

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

# asterisk -rvv
Asterisk 16.2.1, 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.2.1 currently running on rhel8 (pid = 15366)
rhel8*CLI> core show channels
Channel              Location             State   Application(Data)             
0 active channels
0 active calls
0 calls processed
rhel8*CLI> core show  uptime 
System uptime: 6 minutes, 37 seconds
Last reload: 6 minutes, 37 seconds
rhel8*CLI> quit
Asterisk cleanly ending (0).
Executing last minute cleanups

第9步:安装freepbx

如果我们需要基于UI的Asterisk管理仪表板,则检查如何在Rhel/CentOS上安装FreePBX