How to Install Asterisk on Debian 9

How to Install Asterisk on Debian 9

In this tutorial, we will walk you through the installation of Asterisk on a Debian 9 VPS.  Asterisk is the most popular open source software implementation of a telephone private branch exchange (PBX). It includes both classical PBX functionality and many advanced features such as: conference calling, call recorder, voicemail, interactive voice response, automatic call distribution, real time monitoring, debugging console and supports most of the standard voice over IP (VOIP) protocols including SIP, d H.323 and MGCP.

Login to your server via SSH and update the packages

Make sure your server OS is fully up-to-date:

apt-get update
apt-get upgrade

Install all required packages and dependencies

Install all required packages on your Asterisk VPS with the following commands:

apt-get install build-essential
apt-get install git-core subversion libjansson-dev sqlite autoconf automake libxml2-dev libncurses5-dev libtool

Download Asterisk

At the time of writing the latest Asterisk version is 15.5.0. Change to the /usr/src/directory with:

cd /usr/src/

and download the asterisk tar archive with the following wget command:

wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-15-current.tar.gz

When the download is completed run the following command to extract the asterisk-15-current.tar.gz file:

tar -zxvf asterisk-15-current.tar.gz

Compile Asterisk

Once the asterisk archive is extracted, change to the asterisk-15.5.0 directory with the following command:

cd /usr/src/asterisk-15.5.0

Use the install_prereq script to install all of the missing packages:

./contrib/scripts/install_prereq install

Depending on the number of the missing packages the installation may take some time, once it is completed the output will look like the following:

#############################################
## install completed successfully
#############################################

Next step is to run the ./configure script which will check your system for missing libraries and binaries and prepare the Asterisk source code for the build process:

./configure

The output of the successful completion should look like the following:

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 :
configure: host-cpu:vendor:os: x86_64 : pc : linux-gnu :

Now that the configuration is completed start the compilation process using the make command:

make

Depending on your system resources the build process may take several minutes and once it is completed the following message will be printed on your console which means that the Asterisk was successfully compiled:

+--------- Asterisk Build Complete ---------+
+ Asterisk has successfully been built, and +
+ can be installed by running:              +
+                                           +
+                make install               +
+-------------------------------------------+

The next step is to run the make install command which will install Asterisk and all compiled Asterisk modules:

make install

Upon successful Asterisk installation you will be presented with the following message on your screen:

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

Run the make samples command to install the Asterisk sample configuration files:

make samples

Install the initialization script so that you can manage your Asterisk service using the systemctl command :

make config

The command above will show no output.

Next install the logrotation script with the following command:

make install-logrotate

You will see the following output indicating that the logrotation configuration has been successfully created:

if [ ! -d "/etc/asterisk/../logrotate.d" ]; then \
        /usr/bin/install -c -d "/etc/asterisk/../logrotate.d" ; \
fi
sed 's#__LOGDIR__#/var/log/asterisk#g' < contrib/scripts/asterisk.logrotate | sed 's#__SBINDIR__#/usr/sbin#g' > contrib/scripts/asterisk.logrotate.tmp
/usr/bin/install -c -m 0644 contrib/scripts/asterisk.logrotate.tmp "/etc/asterisk/../logrotate.d/asterisk"
rm -f contrib/scripts/asterisk.logrotate.

Start Asterisk

Now that you have Asterisk installed on your Debian 9 VPS you can to start the Asterisk service with the following command:

systemctl start asterisk

You can check if the Asterisk service is started by using ther systemctl status command:

systemctl status asterisk

If the service is running you will see the following message:

● asterisk.service - LSB: Asterisk PBX
   Loaded: loaded (/etc/init.d/asterisk; generated; vendor preset: enabled)
   Active: active (running) since Thu 2018-08-09 01:26:50 CDT; 29s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 4996 ExecStart=/etc/init.d/asterisk start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/asterisk.service
           └─5008 /usr/sbin/asterisk

Finally enable the Asterisk service to start on system boot with the following command:

systemctl enable asterisk

That is it. The Asterisk installation on your Debian 9 based server has been completed.


Install Asterisk on Debian 9Of course you don’t have to install Asterisk on Debian 9 yourself if you use our PBX Web Hosting plans, in which case you can simply ask our expert Linux admins to install Asterisk on your Debian 9 VPS for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this on how to install Asterisk on Debian 9, post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

1 thought on “How to Install Asterisk on Debian 9”

Leave a Comment