In this guide, we are looking at how to install Asterisk 18 LTS on CentOS 7. Asterisk is a powerful opensource PBX system, providing a number of useful features to users, used by different kinds of organizations all over the world. Some of the cool features of Asterisk PBX system are listed below:

  • Conference calling
  • Call Monitoring
  • Call Recording
  • Distributed Universal Number Discovery
  • SMS Messaging
  • Trunking
  • Transcoding
  • Voicemail
  • Caller ID on Call Waiting
  • Direct Inward System Access
  • Call Parking

Follow the below steps to install Asterisk 18 LTS on CentOS 7

Step 1: Update System packages

Ensure that your system packages are upto date before beginning installations. Run the below command:

sudo yum -y update

Reboot the system once upgraded:

sudo reboot

Step 2: Set SELinux in Permissive

I am going to set SElinux in Permissive mode so as not to prevent any installations

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

You can confirm using the commands:

$ getenforce
$ sestatus

Step 3: Install required Packages

There are a number of packages that Asterisk require to be installed. Run the below command to install them:

sudo yum install -y epel-release dmidecode gcc-c++ ncurses-devel libxml2-devel make wget openssl-devel newt-devel kernel-devel sqlite-devel libuuid-devel gtk2-devel jansson-devel binutils-devel libedit libedit-devel wget

Also install Development Tools group packages with the below command:

sudo yum -y groupinstall "Development Tools"

Step 4: Install Jansson on CentOS 7

Jansson is a C library for encoding, decoding and manipulating JSON data. Clone from Github and install as below:

cd /usr/src/ 
sudo git clone 
cd jansson 
sudo autoreconf  -i 
sudo ./configure --prefix=/usr/ 
sudo make 
sudo make install

Step 5: Install PJSIP on CentOS 7

PJSIP is a free and open source multimedia communication library. It implements standard based protocols such as SIP, SDP, RTP, STUN, TURN, and ICE. Download the latest version from the official website using wget, extract and install as below:

cd /usr/src
sudo wget
sudo tar xvf 2.10.tar.gz
cd pjproject-2.10
sudo ./configure CFLAGS="-DNDEBUG -DPJ_HAS_IPV6=1" --prefix=/usr --libdir=/usr/lib64 --enable-shared --disable-video --disable-sound --disable-opencore-amr
sudo make dep
sudo make 
sudo make install
sudo ldconfig

Check all libraries are installed with the following command:

$ ldconfig -p | grep pj (libc6,x86-64) => /lib64/ (libc6,x86-64) => /lib64/ (libc6,x86-64) => /lib64/ (libc6,x86-64) => /lib64/ (libc6,x86-64) => /lib64/ (libc6,x86-64) => /lib64/ (libc6,x86-64) => /lib64/ (libc6,x86-64) => /lib64/ (libc6,x86-64) => /lib64/ (libc6,x86-64) => /lib64/ (libc6,x86-64) => /lib64/ (libc6,x86-64) => /lib64/ (libc6,x86-64) => /lib64/ (libc6,x86-64) => /lib64/ (libc6,x86-64) => /lib64/ (libc6,x86-64) => /lib64/ (libc6,x86-64) => /lib64/ (libc6,x86-64) => /lib64/ (libc6,x86-64) => /lib64/ (libc6,x86-64) => /lib64/ (libc6,x86-64) => /lib64/ (libc6,x86-64) => /lib64/ (libc6,x86-64) => /lib64/ (libc6,x86-64) => /lib64/

Step 6: Install Asterisk 18 LTS on Centos 7

Visit Asterisk official website and download the latest version or use wget to get it directly to your terminal and extract it.

cd /usr/src
sudo wget
sudo tar xvf asterisk-18-current.tar.gz
cd asterisk-18.1.1

To enable mp3 music to play when on hold, run the following commands to install the required dependencies.

$ sudo yum install svn
$ sudo ./contrib/scripts/
A    addons/mp3 
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 
A    addons/mp3/decode_ntom.c 
A    addons/mp3/interface.c 
Exported revision 202.

Now run configure script to prepare package for compiling

$ sudo contrib/scripts/install_prereq install
$ sudo ./configure --libdir=/usr/lib64 --with-jansson-bundled
checking for pkg-config... /bin/pkg-config 
checking pkg-config is at least version 0.9.0... yes 
checking for GTK2... yes 
configure: creating ./config.status 
config.status: creating makeopts 
config.status: creating autoconfig.h 
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$$$$$$  $$       

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 :

Let’s now start build process

sudo make menuselect

You should get a list of features to enable. Use arrow keys to navigate and ‘ENTER’ key to select On Add-ons select chan_ooh323 and format_mp3  as shown below:

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

For Music on Hold,select the shown packages

On Extra Sound Packages select as shown below:

Under applications section, enable app-macro

Once done, click on ‘Save & Exit’ then run the below commands to finish up

$ sudo make
$ sudo make install
+---- Asterisk Installation Complete -------+ 
+                                           + 
+                                           + 
+ 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

sudo make samples

To start Asterisk on boot:

sudo make config

Now create a separate user to run Asterisk services and update ownership of directories

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/lib64/asterisk

Set Asterisk default user to asterisk:

$ sudo vim /etc/sysconfig/asterisk 

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

Restart asterisk after making the above changes.

sudo systemctl restart asterisk

Confirm status

$ sudo systemctl status asterisk
 Loaded: loaded (/etc/rc.d/init.d/asterisk; bad; vendor preset: disabled) 
  Active: active (running) since Fri 2021-01-15 12:39:16 EAT; 7min ago 
    Docs: man:systemd-sysv-generator(8) 
 Process: 103551 ExecStart=/etc/rc.d/init.d/asterisk start (code=exited, status=0/SUCCESS) 
Main PID: 103579 (asterisk) 
  CGroup: /system.slice/asterisk.service 
          ├─103576 /bin/sh /usr/sbin/safe_asterisk -U asterisk -G asterisk 
          └─103579 /usr/sbin/asterisk -f -U asterisk -G asterisk -vvvg -c

Enable Asterisk to start on boot

sudo systemctl enable asterisk

Test if you can connect to Asterisk CLI

$ sudo asterisk -rvv 
Asterisk 18.1.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. 
Connected to Asterisk 18.1.1 currently running on app3 (pid = 104461) 

We have successfully installed Asterisk 18 LTS on CentOS. I hope the guide has been useful. Watch out for more PBX system installation guides in our coming tutorials.

We have more interesting articles you can read on our website:

How To Install Wiki.js on Debian 10 (Buster)

How To Install Nerd Fonts on Linux | macOS

Install and Configure Kitty Terminal Emulator on Linux | macOS

Install and Use doctl to manage DigitalOcean resources


Please enter your comment!
Please enter your name here