Linux Administrator

How To Setup Basic Asterisk Server on CentOS 7

In simple world Asterisk is an open source framework that can be used for building communications applications like IP PBX, VoIP Gateway and other solutions. Asterisk is a open source PBX software packages, which is used to convert normal computer into a communications server.

In this article I am going to explain how you can setup a basic Asterisk server.

Setup Basic Asterisk Server

Follow the below steps to configure basic Asterisk server.

1. Download and Install the Prerequisites packages: First of all you have to download and install prerequisites packages using yum command:

# yum -y install make wget openssl-devel ncurses-devel subversion newt newt-static newt-devel libxml2-devel kernel-devel gcc gcc-c++ mysql sqlite-devel uuid-devel libuuid-devel speex-devel libuuid libxslt uriparser

Now you have to download and install “Jansson” package for Asterisk server.

# cd /usr/src/
# wget
# tar -xvf jansson-2.10.tar.gz
# cd jansson-2.10
# ./configure
# make && make install && make check

You will get some output like below:

make[3]: Entering directory `/usr/src/jansson-2.10/test'
make[4]: Entering directory `/usr/src/jansson-2.10/test'
PASS: run-suites
Testsuite summary for jansson 2.10
# TOTAL: 1
# PASS: 1
# SKIP: 0
# XFAIL: 0
# FAIL: 0
# XPASS: 0
# ERROR: 0
make[4]: Leaving directory `/usr/src/jansson-2.10/test'
make[3]: Leaving directory `/usr/src/jansson-2.10/test'
make[2]: Leaving directory `/usr/src/jansson-2.10/test'
make[1]: Leaving directory `/usr/src/jansson-2.10/test'
make[1]: Entering directory `/usr/src/jansson-2.10'
make[1]: Leaving directory `/usr/src/jansson-2.10'

Now you have to download the Asterisk, DAHDI and Libpri  package.

Download Asterisk Package

# mkdir -p /usr/src/asterisk
# cd /usr/src/asterisk
# wget

Download DAHDI and Libpri Package

# wget
# wget

DAHDI stands for Digium Asterisk Hardware Device Interface.

Configure DAHDI

# tar -xvf dahdi-linux-complete-current.tar.gz
# cd dahdi-linux-complete-2.11.1+2.11.1/
# make
# make install
# make config

Install Libpri Package

Libpri package is used to connect to a PRI service.

# tar -xvf libpri-current.tar.gz
# cd libpri-1.6.0
# make
# make install

Install Asterisk Package

Now install Asterisk package following below command:

# cd /usr/src/asterisk
# tar -xvf asterisk-14-current.tar.gz
# cd asterisk-14.5.0
# ./configure --libdir=/usr/lib64

You will get some 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$$$$$$  $$

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 :

Note :- If you are installing Asterisk on 32-bit operating system then you don’t need to mention library directory.

Now run the below command:

# make menuselect && make && make install && make samples && make config

You will get someput like below:

Installing file configs/samples/udptl.conf.sample
Installing file configs/samples/unistim.conf.sample
Installing file configs/samples/users.conf.sample
Installing file configs/samples/voicemail.conf.sample
Installing file configs/samples/vpb.conf.sample
Installing file configs/samples/xmpp.conf.sample
Updating asterisk.conf
/usr/bin/install -c -d "/var/spool/asterisk/voicemail/default/1234/INBOX"
build_tools/make_sample_voicemail "//var/lib/asterisk" "//var/spool/asterisk"
Installing file phoneprov/000000000000.cfg
Installing file phoneprov/000000000000-directory.xml
Installing file phoneprov/000000000000-phone.cfg
Installing file phoneprov/polycom_line.xml
Installing file phoneprov/polycom.xml
Installing file phoneprov/snom-mac.xml

2. Enable and Start Asterisk Service: Now restart and enable the Asterisk service using below command:

# /etc/init.d/asterisk start
Starting asterisk (via systemctl):                        [  OK  ]

Check Asterisk Status

# /etc/init.d/asterisk status
● asterisk.service - LSB: Asterisk PBX
   Loaded: loaded (/etc/rc.d/init.d/asterisk; bad; vendor preset: disabled)
   Active: active (running) since Thu 2017-06-01 03:11:00 EDT; 4s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 16068 ExecStart=/etc/rc.d/init.d/asterisk start (code=exited, status=0/SUCCESS)
 Main PID: 16093
   CGroup: /system.slice/asterisk.service
           ├─16091 /bin/sh /usr/sbin/safe_asterisk
           └─16096 sleep 4

Jun 01 03:10:59 astserver systemd[1]: Starting LSB: Asterisk PBX...
Jun 01 03:10:59 astserver asterisk[16068]: Starting asterisk:
Jun 01 03:10:59 astserver systemd[1]: PID file /var/run/asterisk/ not readable (yet?) after start.
Jun 01 03:11:00 astserver systemd[1]: asterisk.service: Supervising process 16093 which is not our child. We'll most likely not notice when it exits.
Jun 01 03:11:00 astserver systemd[1]: Started LSB: Asterisk PBX.
# /sbin/chkconfig asterisk on
# chkconfig --list | grep asterisk

3. Connect To Asterisk CLI: Now connect to Asterisk CLI mode using below command:

#  asterisk -rvvvv
Asterisk 14.5.0, Copyright (C) 1999 - 2016, 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 14.5.0 currently running on astserver (pid = 2491)

If your facing below error, then you have to disable SELinux.

#  asterisk -rv
Unable to connect to remote asterisk (does /var/run/asterisk/asterisk.ctl exist?)


Thank you! for visiting LookLinux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website To become an author at Look Linux Submit Article. Stay connected to Facebook.

About the author


Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Leave a Comment