访问 Asterisk CLI:
使用以下命令连接到 Asterisk CLI。
# asterisk -r Asterisk 18.1.0, Copyright (C) 1999 - 2018, Doirum, Inc. and others. Created by Mark Spencer <markster@doirum.com> 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 18.1.0 currently running on asterisk-pbx (pid = 2350) asterisk-pbx*CLI>
让我们在 Asterisk CLI 上执行一些常用命令。
asterisk-pbx*CLI> core show channels Channel Location State Application(Data) 0 active channels 0 active calls 0 calls processed asterisk-pbx*CLI> core show uptime System uptime: 1 hour, 29 minutes, 59 seconds Last reload: 1 hour, 29 minutes, 59 seconds asterisk-pbx*CLI> quit Asterisk cleanly ending (0). Executing last minute cleanups
下载 Asterisk VoIP 软件:
Asterisk 是一个免费软件,你可以从他们的官方网站或者 GitHub Repository 下载它。
使用 wget 命令从复制的 URL 下载软件安装程序。
# wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-18-current.tar.gz
使用 tar 命令解压下载的 tar包。
# tar xf asterisk-18-current.tar.gz
为 VoIP 软件创建操作系统用户:
创建 OS 用户和组以拥有 VoIP 软件目录。
# groupadd asterisk # useradd -r -d /var/lib/asterisk -g asterisk asterisk # usermod -aG audio,dialout asterisk
将所有者更改为以下目录的asterisk用户。
# chown -R asterisk.asterisk /etc/asterisk /var/{lib,log,spool}/asterisk /usr/lib64/asterisk
使用 vim 文本编辑器编辑以下配置文件。
# vi /etc/sysconfig/asterisk
并其中添加以下配置以设置 VoIP 软件的默认用户。
AST_USER="asterisk" AST_GROUP="asterisk"
在 vim 文本编辑器中编辑 asterisk.conf 文件。
# vi /etc/asterisk/asterisk.conf
并添加以下指令以设置默认用户拥有 Asterisk 进程。
runuser = asterisk ; The user to run as. rungroup = asterisk ; The group to run as.
启用并启动asterisk服务。
# systemctl enable --now asterisk
检查 asterisk.service 的状态。
# systemctl status asterisk.service
安装必备软件包:
Asterisk VoIP 软件带有一个编写良好的脚本,可用于在 Linux 服务器上安装必备软件包。
执行此脚本并一次性安装所有必备软件包。
# cd asterisk-18.1.0/contrib/scripts/ # ./install_prereq install
要在客户端挂起时启用 mp3 支持播放音乐,我们需要安装更多依赖项。
幸运的是,安装程序为此提供了一个脚本。
立即执行。
# ./get_mp3_source.sh
Asterisk VoIP 服务器还需要 libedit 和 libedit-devel 包,这些包在标准 yum 存储库中不可用。
因此,我们必须按如下方式从 rpmfind 网站安装这些软件包。
# cd ~/asterisk-18.1.0 # dnf install -y / > https://www.rpmfind.net/linux/centos/8-stream/PowerTools/x86_64/os/Packages/libedit-devel-3.1-23.20170329cvs.el8.x86_64.rpm / > https://www.rpmfind.net/linux/centos/8-stream/BaseOS/x86_64/os/Packages/libedit-3.1-23.20170329cvs.el8.x86_64.rpm
在 CentOS 8 上安装 Asterisk PBX:
现在,我们可以从解压目录开始安装 PBX 软件。
# ./configure --libdir=/usr/lib64 --with-jansson-bundled
构建过程的下一步是告诉 Asterisk 安装程序,要编译和安装哪些模块,以及设置各种编译器选项。
这些设置都通过名为 Menuselect 的菜单驱动系统进行控制。
要访问 Menuselect 系统,请执行以下命令。
# make menuselect
选择要与 PBX 服务器一起安装的所需插件/模块。
根据上述配置编译构建Asterisk VoIP软件。
# 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 + +-------------------------------------------+
在 Linux 服务器上安装 Asterisk VoIP 软件。
# 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 + +-------------------------------------------+
安装示例配置文件如下。
# make samples
安装 Asterisk 示例文件以配置基本 PBX。
# make basic-pbx