Installing Asterisk 16 on Centos 7

Asterisk is a powerful opensource PBX system. It's quite handy for companies that want to create there one private network of company phones. A few key features from Asterisk are; 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, voicemail, and call queues. In today's tutorial, we are going to learn how to install the new asterisk 16 for centos 7. We will do this on an AWS ec2 server.

How to install Asterisk 16 for centos 7

Before we start with installing our Asterisk application on our centos 7 server, let's make sure that all of our packages are up to date on our server.

sudo yum -y update

Let's also set hostname type:

sudo hostnamectl set-hostname pbx.example.com

And add EPEL repository

sudo yum -y install epel-release

The last step is to set the selinux in Permissive Mode by running the commands below:

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

Now let's start with installing asterisk.

Step 1: Install the dependencies that are needed for Asterisk 16

sudo yum -y install wget vim net-tools

You also need to install Development Tools group packages.

sudo yum -y groupinstall "Development Tools"

The other packages that you need to install are:

sudo yum -y install libedit-devel sqlite-devel psmisc gmime-devel ncurses-devel libtermcap-devel sox newt-devel libxml2-devel libtiff-devel audiofile-devel gtk2-devel uuid-devel libtool libuuid-devel subversion kernel-devel kernel-devel-$(uname -r) git subversion kernel-devel crontabs cronie cronie-anacron wget vim

Step 2: Download and Install Jansson

The next step is to install Jansson C library on our ec2 instance. Jansson is a C library for encoding, decoding and manipulating JSON data.

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

Step 3: 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/ 
export VER="2.10"
wget https://github.com/pjsip/pjproject/archive/${VER}.tar.gz
tar -xvf ${VER}.tar.gz
cd pjproject-${VER}
./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 4: Download and Install Asterisk

Now that we have all dependency packages installed, we should be ready to download and install Asterisk 16 for our CentOS 7 instance.

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-*
./configure --libdir=/usr/lib64

When the installation has been finished you will see an output like this.

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

Step 5: Set Asterisk menu options

Setup menu options by running the following command:

make menuselect

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

  • On Add-ons select chan_ooh323 and format_mp3.
  • On Core Sound Packages, select the formats of Audio packets sounds-en-wav, sounds-en-ulaw, sounds-en-alaw​.
  • For Music On Hold, select the following minimal modules
  • On Extra Sound Packages select as sounds-en-wav, sounds-en-ulaw, sounds-en-alaw
  • Enable app_macro under Applications section.

You can change other configurations you see fit. When done, save and exit. After this let's run the following command to download the mp3 decoder library into the source tree.

sudo contrib/scripts/get_mp3_source.sh

To start building and installation of Asterisk with selected modules, run the commands.

make
make install
make samples
make config
ldconfig

The output will be like this after the installlation for asterisk has been done.

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

Now we need to create a seperated user to run Asterisk with the right permissions.

groupadd asterisk
useradd -r -d /var/lib/asterisk -g asterisk asterisk
usermod -aG audio,dialout asterisk
chown -R asterisk.asterisk /etc/asterisk
chown -R asterisk.asterisk /var/{lib,log,spool}/asterisk
chown -R asterisk.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 on boot:

sudo systemctl enable asterisk

Now let's test if asterisk 16 has been succesfully installed on our centos 7 application.

asterisk -rvv

This will give an output as followed.

Asterisk 16.0.1, 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 16.0.1 currently running on centos-01 (pid = 17182)
centos-01*CLI> 

We have now successfully installed Asterisk 16 on our Amazon AWS ec2 centos 7 instances. If you have questions or need any help, you can always contact us through our contact form.

Wesley

Webdeveloper

Installing Asterisk 16 on Centos 7

Have questions about our services?

Contact our Sales team to get answers.

Contact Us