Install Asterisk PBX Server on CentOS / RHEL 8 - CentLinux

Latest

Saturday, 28 November 2020

Install Asterisk PBX Server on CentOS / RHEL 8

Install Asterisk PBX Server on CentOS / RHEL 8

Asterisk is software implementation of Personal Branch Exchange (PBX). In this guide, you will learn how to install VoIP server on CentOS / RHEL 8.

 

Table of Contents:

 

What is PBX? :

PBX is a telephone exchange or switching system that serves a private organization and permits sharing of central office trunks between internally installed telephones, and provides intercommunication between those internal telephones within the organization without the use of external lines. The central office lines provide connections to the public switched telephone network (PSTN) and the concentration aspect of a PBX permits the shared use of these lines between all stations in the organization. Its intercommunication ability allows two or more stations to directly connect while not using the public switched telephone network. This method reduces the number of lines needed from the organization to the public switched telephone network.

 

What is Asterisk PBX? :

Asterisk is a software implementation of a private branch exchange (PBX). In conjunction with suitable telephony hardware interfaces and network applications, it is used to establish and control telephone calls between telecommunication endpoints, such as customary telephone sets, destinations on the public switched telephone network (PSTN), and devices or services on voice over Internet Protocol (VoIP) networks. Its name comes from the asterisk (*) symbol for a signal used in dual-tone multi-frequency (DTMF) dialing.

Asterisk was created in 1999 by Mark Spencer of Digium, which since 2018 is a division of Sangoma Technologies Corporation. Originally designed for Linux, Asterisk runs on a variety of operating systems, including NetBSD, OpenBSD, FreeBSD, macOS, and Solaris, and can be installed in embedded systems based on OpenWrt (Open Wireless Router). (Source: Wikipedia)

Asterisk PBX is available in Community and Commercial editions. Community edition is a free software and distributed under GPLv2 license. Whereas, Commercial edition provides enterprise features but have a licensing cost.

 

Asterisk Features:

Some popular features of Asterisk are.

  • Voice over IP (VoIP)
  • Voice Mail
  • Conference Calling
  • Interactive Voice Response (Phone Menus)
  • Automatic Call Distribution
  • Supports common VoIP, ISDN protocols

Complete list of Asterix PBX features is available on their official website.

 

Environment Specification:

We are using a minimal CentOS 8 virtual machine with following specifications.

  • CPU - 3.4 Ghz (2 cores)
  • Memory - 2 GB
  • Storage - 20 GB
  • Operating System - CentOS 8.2
  • Hostname – asterisk-pbx.centlinux.com
  • IP Address - 192.168.116.236 /24

 

Update Linux Software Packages:

Connect with asterisk-pbx.centlinux.com as Linux root user by using a ssh client.

By following the best practice, update your Linux operating system before installing Asterisk VoIP software.

Use dnf command to update software packages of your Linux server.

# dnf update -y
Last metadata expiration check: 0:00:30 ago on Wed 25 Nov 2020 08:24:39 PM PKT.
Dependencies resolved.
Nothing to do.
Complete!

All packages in our Linux operating system are already up-to-date.

Check Kernel version of your Linux server.

# uname -r
4.18.0-193.28.1.el8_2.x86_64

Check Linux operating system version.

# cat /etc/redhat-release
CentOS Linux release 8.2.2004 (Core)

 

Download Asterisk VoIP Software:

Asterisk is a free software and you can download it from their official website or GitHub Repository.

Open Asterisk website in a web browser and copy the URL of the software setup. Currently version 18 is the latest version, and it is available for download.

01-install-asterisk-pbx-server-on-centos-8-download

 

Use wget command to download the software installer from the copied URL.

# wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-18-current.tar.gz
--2020-11-25 20:55:00--  http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-18-current.tar.gz
Resolving downloads.asterisk.org (downloads.asterisk.org)... 76.164.171.238, 2001:470:e0d4::ee
Connecting to downloads.asterisk.org (downloads.asterisk.org)|76.164.171.238|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 27886299 (27M) [application/x-gzip]
Saving to: âasterisk-18-current.tar.gzâ

asterisk-18-current 100%[===================>]  26.59M   949 B/s    in 82s

2020-11-25 20:56:24 (331 KB/s) - âasterisk-18-current.tar.gzâ saved [27886299/27886299]

Extract the downloaded tarball by using tar command.

# tar xf asterisk-18-current.tar.gz

 

Installing Prerequisite Packages:

Asterisk VoIP software comes with a well written script that can be used to install prerequisite software packages on Linux servers.

Execute this script and install all prerequisite packages in one go.

# cd asterisk-18.1.0/contrib/scripts/
# ./install_prereq install

01-asterisk-install-prereq-output

To enable mp3 support for playing music while the client is on hold, you are required to install a few more dependencies. Luckily, the installer provides a script for the same. Execute it now.

# ./get_mp3_source.sh

02-get-mp3-source-output

Asterisk VoIP server also required libedit and libedit-devel packages, that are not available in standard yum repositories. Therefore, you have to install these packages from rpmfind website as follows.

# 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

03-dnf-install-libedit-devel

All prerequisites have been installed successfully.

 

Installing Asterisk PBX on CentOS 8:

Now, you can start setup of PBX software from extracted directory.

# ./configure --libdir=/usr/lib64 --with-jansson-bundled

04-configure-asterisk-pbx

The next step in the build process is to tell Asterisk installer, which modules to compile and install, as well as set various compiler options. These settings are all controlled via a menu-driven system called Menuselect. To access the Menuselect system, execute the following command.

# make menuselect

05-asterisk-make-menuselect-output

02-install-asterisk-pbx-server-on-centos-8-menuselect

Select the required addons/modules that you want to install with the PBX server.

Compile and build the Asterisk VoIP software based on the above configurations.

# 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               +
 +-------------------------------------------+

Install the Asterisk VoIP software on your Linux server.

# 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    +
 +-------------------------------------------+

Install sample configuration files as follows.

# make samples

06-asterisk-make-samples-output

Install Asterisk sample files to configure basic PBX.

# make basic-pbx

07-asterisk-make-basic-pbx

 

Create OS User for VoIP Software:

Create OS user and group to own VoIP software directory.

# groupadd asterisk
# useradd -r -d /var/lib/asterisk -g asterisk asterisk
# usermod -aG audio,dialout asterisk

Change owner to asterisk user of following directories.

# chown -R asterisk.asterisk /etc/asterisk /var/{lib,log,spool}/asterisk /usr/lib64/asterisk

Edit following configuration file by using vim text editor.

# vi /etc/sysconfig/asterisk

And add following configurations therein to set default user for VoIP software.

AST_USER="asterisk"
AST_GROUP="asterisk"

Edit asterisk.conf file in vim text editor.

# vi /etc/asterisk/asterisk.conf

And add following directives to set default user to own Asterisk processes.

runuser = asterisk ; The user to run as.
rungroup = asterisk ; The group to run as.

Enable and start Asterisk service.

# systemctl enable --now asterisk

Check the status of asterisk.service.

# systemctl status asterisk.service

08-systemctl-status-asterisk

 

Accessing Asterisk CLI:

Connect to Asterisk CLI by using following command.

# asterisk -r
Asterisk 18.1.0, Copyright (C) 1999 - 2018, Digium, Inc. and others.
Created by Mark Spencer <markster@digium.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>

Let's execute some common commands on 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 server has been installed on Linux operating system and working fine.

 

Conclusion:

In this guide, you have learned how to install Asterisk PBX server on CentOS / RHEL 8. To configure Asterisk as a PBX for your corporate environment, you might read Asterisk: The Definitive Guide: Open Source Telephony for the Enterprise by O'Reilly Media.

No comments:

Post a Comment