(Last Updated On: March 23, 2019)

Welcome to our guide on how to install Asterisk 16 LTS on CentOS / RHEL 8. Asterisk is a popular and powerful open source PBX system with features similar to those found only in commercial PBX systems. Asterisk powers IP PBX systems, VoIP gateways, conference servers and call centers, both in SMB and enterprise setups.

Features of Asterisk PBX system

  • Conference calling
  • Call Recording
  • Call Monitoring
  • Distributed Universal Number Discovery
  • Caller ID on Call Waiting
  • Direct Inward System Access
  • Call Parking
  • SMS Messaging
  • Trunking
  • Transcoding
  • Automated Attendant
  • Voicemail
  • Music on Hold
  • Music on Transfer
  • Authentication
  • Blacklists
  • Alarm receiver
  • Call Queues and many other features.

In our recent guides, we covered:

How to Install Asterisk 16 LTS on Ubuntu / Debian

How to Install Asterisk 16 LTS on CentOS 7 / Fedora

Install Asterisk 16 LTS on CentOS / RHEL 8

Before you start Asterisk installation:

  • set the timezone for your server.
  • Set SELinux  in Permissive mode by running the commands below:
sudo setenforce 0
sudo sed -i 's/\(^SELINUX=\).*/\SELINUX=permissive/' /etc/selinux/config

Then follow the steps below to install and configure Asterisk 16 LTS on your CentOS / RHEL 8 server.

Step 1: Add EPEL Repository

Ensure you have EPEL repository added to your RHEL / CentOS 8 system by following our guide below.

How to Install EPEL repository on RHEL / CentOS 8

Step 2: Install Development Tools

Install software Development tools and other dependencies required for building and running Asterisk on RHEL / CentOS 8.

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

Step 3: Download and Install Jansson

Jansson is a C library for encoding, decoding and manipulating JSON data. Download and install it on CentOS / RHEL 8 server by running the commands below:

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

Step 4: Download and Install PJSIP

PJSIP is a free and open source multimedia communication library written in C language implementing standard based protocols such as SIP, SDP, RTP, STUN, TURN, and ICE.

Clone the project from Github, then compile and install.

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

Step 5: Download and Install Asterisk

Now that we have all dependency packages installed, we should be ready to download and install Asterisk 15 on CentOS / RHEL 8.

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*/

Install libedit packages.

sudo dnf -y install https://rpmfind.net/linux/fedora/linux/releases/29/Everything/x86_64/os/Packages/l/libedit-3.1-24.20170329cvs.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.20170329cvs.fc29.x86_64.rpm

Configure Asterisk.

./configure --libdir=/usr/lib64

A successful configuration should print output like below.

.....
configure: Menuselect build configuration successfully completed

               .$$$$$$$$$$$$$$$=..      
            .$7$7..          .7$$7:.    
          .$$:.                 ,$7.7   
        .$7.     7$$$$           .$$77  
     ..$$.       $$$$$            .$$$7 
    ..7$   .?.   $$$$$   .?.       7$$$.
   $.$.   .$$$7. $$$$7 .7$$$.      .$$$.
 .777.   .$$$$$$77$$$77$$$$$7.      $$$,
 $$$~      .7$$$$$$$$$$$$$7.       .$$$.
.$$7          .7$$$$$$$7:          ?$$$.
$$$          ?7$$$$$$$$$$I        .$$$7 
$$$       .7$$$$$$$$$$$$$$$$      :$$$. 
$$$       $$$$$$7$$$$$$$$$$$$    .$$$.  
$$$        $$$   7$$$7  .$$$    .$$$.   
$$$$             $$$$7         .$$$.    
7$$$7            7$$$$        7$$$      
 $$$$$                        $$$       
  $$$$7.                       $$  (TM)     
   $$$$$$$.           .7$$$$$$  $$      
     $$$$$$$$$$$$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 :

Step 6: Set Asterisk menu options

Setup menu options by running the following command:

make menuselect

Use arrow keys to navigate, and Enter key to select.

1. Under Add-ons select chan_ooh323 and format_mp3  as shown below

2. On Core Sound Packages, select the formats of Audio packets like below

3. For Music On Hold, select the following minimal modules

5. On Extra Sound Packages select as shown below:

6. Enable app_macro under Applications section.

Feel free to modify other settings to suit your needs then save and exit when done.

Step 7: Build and Install Asterisk

Run the following command to download the mp3 decoder library into the source tree.

sudo contrib/scripts/get_mp3_source.sh

Build and install Asterisk on RHEL / CentOS 8.

make
make install
make samples
make config
ldconfig

Step 8: Configure and Start Asterisk

Create a separate user and group to run asterisk services, and assign correct permissions:

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

Set Asterisk default user to 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.

Restart asterisk service after making the changes

sudo systemctl restart asterisk

Enable service to start at boot:

sudo systemctl enable asterisk

Confirm service status.

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

Test to see if you can connect to Asterisk CLI:

# asterisk -rvv
Asterisk 16.2.1, Copyright (C) 1999 - 2018, Digium, Inc. and others.
Created by Mark Spencer [email protected]
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

Step 9: Install FreePBX

If you need a UI based administrative dashboard for Asterisk, then check How to Install FreePBX on RHEL / CentOS 8

Conclusion

You now have a running Asterisk 16 LTS on CentOS / RHEL 8 server. In our next how-to guide, we will cover the installation and Configuration of FreePBX on RHEL / CentOS 8. Stay tuned and drop a comment if you encounter any issues with the setup.

Further reading: How to secure Asterisk and FreePBX from VoIP Fraud and Bruteforce attacks