Template is not defined.

Part 2 – Installing Asterisk: The Best Guide to Understanding Asterisk

Introduction

Installing Asterisk is the first step to setting up a robust telephony system tailored to your specific requirements. In this article, we will explore the step-by-step process of installing Asterisk, enabling you to set up a robust telephony system tailored to your specific requirements. Whether you are a small business owner or a telecom professional, this guide will equip you with the knowledge to successfully deploy Asterisk.

It is expected that you know about Asterisk and how it is used. Now, it’s time to get you up and running with your own Asterisk installation.

Hardware and Software Requirements

For our Lab, We shall be using Ubuntu 16.04 in Oracle’s VM Virtual box bridge mode. Now there are newer versions of Ubuntu, however, because most real-world systems are still working with older Linux versions, for this Tutorial we shall work with Ubuntu 16.04 so you can familiarize yourself with real-world examples. However, for newer installations, You may want to use newer versions.

It should be known that 85% or more of Asterisk users have less than 25 simultaneous calls and no more than 200 users. while about 20% have about 3000 simultaneous calls. So if you are expecting less than 30 Simultaneous calls, then any modern server should work fine.
But if you expect 1000 to 3000 simultaneous calls then you must first test your server config using SIPp. Use a large Security Coefficient (SC). So if the Test get 3000 Simultaneous calls, Use a SC=4 and dimension for no more than 750 users.

Flavio E. Goncalves

Lab Minimum Hardware and Software Specifications

for this Tutorial, Below is the minimum specs required

  • Oracle’s VM Virtual box bridge mode
  • At least 2GB RAM, 20GB Disk Space
  • Ubuntu 16.04, 32Bits (or you may use 64Bits)

See also, Dimensioning Asterisk for more information on Asterisk Dimensioning with real-world examples.

Also, The choice between telephony cards and SIP trunking depends on the specific requirements, infrastructure, and preferences of an organization. However, considering the benefits of SIP trunking, it is highly recommended over Physical cards.

Downloading Asterisk

There have been different versions of Asterisk since its inception. A complete listing of download options can be found on the Asterisk Downloads Server.

Installing Asterisk

The Table below, “Asterisk Versions” Shows the Different version Available and their support period, for newer installations. I would recommend that you select the newer version with a LTS. A Long Term Support (LTS) release will be fully supported for 4 years, with one additional year of maintenance for security fixes. Standard releases are supported for a shorter period of time, which will be at least one year of full support and an additional year of maintenance for security fixes.

Table 1.0 – Asterisk Versions

Release SeriesRelease TypeRelease DateSecurity Fix OnlyEOL
1.2.x 2005-11-212007-08-072010-11-21
1.4.xLTS2006-12-232011-04-212012-04-21
1.6.0.xStandard2008-10-012010-05-012010-10-01
1.6.1.xStandard2009-04-272010-05-012011-04-27
1.6.2.xStandard2009-12-182011-04-212012-04-21
1.8.xLTS2010-10-212014-10-212015-10-21
10.xStandard2011-12-152012-12-152013-12-15
11.xLTS2012-10-252016-10-252017-10-25
12.xStandard2013-12-202014-12-202015-12-20
13.xLTS2014-10-242020-10-242021-10-24
14.xStandard2016-09-262017-09-262018-09-26
15.xStandard2017-10-032018-10-032019-10-03
16.xLTS2018-10-092022-10-092023-10-09
17.xStandard2019-10-282020-10-282021-10-28
18.xLTS2020-10-202024-10-202025-10-20
19.xStandard2021-11-022022-11-022023-11-02
20.xLTS2022-10-192026-10-192027-10-19
21.xStandard2023-10-182025-10-182026-10-18
Asterisk versions. Source: https://wiki.asterisk.org/wiki/display/AST/Asterisk+Versions

Standard Asterisk Install Methods

There are various ways to get started with Asterisk on your own system:

  1. Use distros like FreePBX (formally called AsteriskNow) that handles Asterisk-based distribution. This takes care of installing Linux, Asterisk, and a web-based management interface (Graphical User Interface) all at the same time. FreePBX is the easiest way to get started if you’re new to Linux and/or Asterisk.
  2. If you’re already familiar with Linux or Unix, you can simply install packages for Asterisk and its related tools using the package manager in your operating system. We’ll cover this in more detail below in Alternate Install Methods.
  3. For the utmost control of your installation, you can compile and install Asterisk (and its related tools) from the source code.

Alternate Install Methods

Here are the two common methods:

METHOD 1: Installing Asterisk Using Package Managers

Package managers provide a convenient way to install and manage software packages, including Asterisk, on your system. The package manager handles dependencies and simplifies the installation process.
The availability of Asterisk packages in package managers may vary depending on the Linux distribution you are using. Note that the package managers usually don’t have official maintainers and will sometimes not install the latest version. You may need to update to the latest version. Some popular package managers include:

To download Asterisk using a package manager, you can follow the instructions based on the package manager and Linux distribution you are using. Here are the general steps for some common package managers: First, Open a terminal:

  • APT (Advanced Package Tool) – Used by Debian-based distributions like Ubuntu:
    • sudo apt update – To update the package lists
    • After the package lists are updated, run the following command to install Asterisk:
    • sudo apt install asterisk
    • You can now check the asterisk version using asterisk -V command to confirm that you have the latest version.
    • Optionally, use the sudo apt upgrade asterisk terminal command to update to the latest version if the installed package version is not the latest.
  • YUM (Yellowdog Updater, Modified) – Used by Red Hat-based distributions like CentOS:
    • sudo yum update – To update the package lists
    • After the package lists are updated, run the following command to install Asterisk:
      sudo yum install asterisk
    • sudo yum upgrade asterisk to upgrade Asterisk and its dependencies
  • DNF (Dandified YUM) – Used by Fedora and newer versions of CentOS:
    • Run the following command to update the package lists:
      sudo dnf update
    • After the package lists are updated, run the following command to install Asterisk:
      sudo dnf install asterisk
    • sudo dnf upgrade asterisk to upgrade Asterisk and its dependencies
  • Pacman package manager on Arch Linux
    • Run sudo pacman -Sy to Update the package repositories
    • Run sudo pacman -S asterisk to install Asterisk
    • Run sudo pacman -Syu asterisk to upgrade Asterisk to the latest version

These commands will download and install the Asterisk package along with its dependencies using the package manager. Make sure you have the necessary privileges (such as using sudo) to install packages.

  • apt-get (for Debian-based distributions like Ubuntu)
  • yum or dnf (for Red Hat-based distributions like CentOS)
  • Pacman (for Arch Linux)

METHOD 2: Installing Asterisk from Source Code (stable releases)

The Asterisk source code can be accessed from the official Asterisk GitHub repository at https://github.com/asterisk/asterisk, clone the repository or download the source code as a ZIP archive from the release page.

Alternatively, go to http://downloads.asterisk.org/pub/telephony/asterisk/ to access the stable releases, navigate to the “Releases” directory repository. that is: visit http://downloads.asterisk.org/pub/telephony/asterisk/releases/ and select the version you want to download and install. There, you will find the list of releases, including their version numbers and tags. Click on the desired release to access the corresponding source code. or copy the compressed link (usually in asterisk-**.tar.gz format)

Step 1: Update System files and Dependencies

In the terminal, Update system package repositories and Install the necessary dependencies. Refer to the official Asterisk documentation or the specific installation guide for the complete list of dependencies required for your version of Asterisk.:

sudo apt update
sudo apt install ssh
sudo apt-get upgrade
sudo apt install patch
sudo apt install git curl subversion
sudo apt install build-essential openssl libssl-dev libxml2-dev libncurses5-dev libsqlite3-dev uuid-dev sqlite autoconf automake libtool libjansson-dev  libedit-dev  libopus-dev libspeex-dev

Step 2: Download Asterisk

move to the src folder and download the asterisk version of your choice using the copied link.

cd /usr/src

wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-18.4.0.tar.gz

tar -xzvf asterisk-18.4.0.tar.gz

mv asterisk-18.4.0 asterisk

cd asterisk

After extracting the compressed file into the directory asterisk-18.4.0 we renamed it to something more readable like asterisk.

Also notice that when extracting with tar, i added the options -xzvf

  • x: This option tells tar you to extract files from the archive.
  • z: This option specifies that the archive is compressed using gzip.
  • v: This option enables verbose mode, which displays detailed output during the extraction process.
  • f: This option indicates that the following argument is the name of the archive file.

Now, run the following command to download the mp3 decoder library into the source tree.

contrib/scripts/get_mp3_source.sh

Finally, confirm dependencies are resolved:

sudo contrib/scripts/install_prereq install

the output should be something like this:

#############################################
## install completed successfully
#############################################
root@AsteriskUBServer:/usr/src/asterisk#

Note, sudo contrib/scripts/install_prereq install and sudo apt install build-essential are not the same. While both commands install prerequisite packages, they serve different purposes:

  1. sudo contrib/scripts/install_prereq install: This command is specific to Asterisk and is provided by the Asterisk project itself. It installs the necessary software packages and libraries required to build and run Asterisk on a Linux system. It ensures that you have all the dependencies needed for Asterisk specifically.
  2. sudo apt install build-essential: This command installs a general set of essential tools and libraries that are commonly needed for building software on a Linux system. It includes packages such as gcc, g++, make, and other development tools. It is a more generic command that installs a broader set of tools, not specific to Asterisk.

While sudo apt install build-essential can install some of the dependencies required for building Asterisk, it may not cover all the specific dependencies that Asterisk needs. Therefore, it is generally recommended to use the Asterisk-specific script, sudo contrib/scripts/install_prereq install, to ensure that all the necessary dependencies are correctly installed for Asterisk.

STEP 3: Compile Asterisk

It’s time to compile asterisk using Jansson.

 ./configure --with-jansson-bundled

By using the --with-jansson-bundled flag, Asterisk will rely on the included version of libjansson rather than searching for a system-wide installation of libjansson. This ensures that the correct version of libjansson is used and avoids potential compatibility issues with different versions of the library.

jansson-bundled refers to the bundled version of the Jansson library that comes with the Asterisk source code. Jansson is a C library for working with JSON (JavaScript Object Notation) data.

the output of this operation should be similar to :

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 : i686
configure: build-cpu:vendor:os: i686 : pc : linux-gnu :
configure: host-cpu:vendor:os: i686 : pc : linux-gnu :
root@AsteriskUBServer:/usr/src/asterisk#

STEP 4: Build Install from Source

 make && make install && make config && make samples

The command make && make install && make config && make samples is a series of build commands typically used after running the ./configure script to build and install Asterisk from source. Let’s break down each command:

  1. make: This command initiates the compilation process based on the instructions defined in the Makefile to build or compile the Asterisk source code into executable binaries.
  2. make install: After successful compilation, the make install command installs the compiled binaries, libraries, and other necessary files to the system. This step ensures that Asterisk is properly installed on your system.
  3. make config: The make config command copies the sample configuration files to their appropriate locations. These sample configuration files provide a starting point for configuring Asterisk according to your requirements. You can modify these files to suit your specific needs.
  4. make samples: The make samples command installs sample configuration files and additional resource files. These files serve as examples and provide further guidance for configuring Asterisk. They can be helpful for understanding different configuration options and features.

By running make && make install && make config && make samples consecutively, you perform a complete build and installation of Asterisk, including the installation of necessary files, sample configurations, and resources. After executing these commands, Asterisk should be ready for further configuration and usage.

You now see the asterisk help menu or check the version number

asterisk -help

asterisk -V

Running the Asterisk CLI

The Asterisk Command Line Interface (CLI) is a powerful tool that provides a command-line interface for interacting with an Asterisk server. It allows you to monitor and control various aspects of the Asterisk system, view logs, debug issues, and perform administrative tasks. After a fresh asterisk install, you can view the asterisk help menu: asterisk -h . the result should be something like this:

root@AsteriskUBServer:/usr/src/asterisk# asterisk -h
Asterisk 18.4.0, Copyright (C) 1999 - 2021, Sangoma Technologies Corporation and others.
Usage: asterisk [OPTIONS]
Valid Options:
   -V              Display version number and exit
   -C <configfile> Use an alternate configuration file
   -G <group>      Run as a group other than the caller
   -U <user>       Run as a user other than the caller
   -c              Provide console CLI
   -d              Increase debugging (multiple d's = more debugging)
   -f              Do not fork
   -F              Always fork
   -g              Dump core in case of a crash
   -h              This help screen
   -i              Initialize crypto keys at startup
   -L <load>       Limit the maximum load average before rejecting new calls
   -M <value>      Limit the maximum number of calls to the specified value
   -m              Mute debugging and console output on the console
   -n              Disable console colorization
   -p              Run as pseudo-realtime thread
   -q              Quiet mode (suppress output)
   -r              Connect to Asterisk on this machine
   -R              Same as -r, except attempt to reconnect if disconnected
   -s <socket>     Connect to Asterisk via socket <socket> (only valid with -r)
   -t              Record soundfiles in /var/tmp and move them where they
                   belong after they are done
   -T              Display the time in [Mmm dd hh:mm:ss] format for each line
                   of output to the CLI
   -v              Increase verbosity (multiple v's = more verbose)
   -x <cmd>        Execute command <cmd> (implies -r)
   -X              Enable use of #exec in asterisk.conf
   -W              Adjust terminal colors to compensate for a light background

root@AsteriskUBServer:/usr/src/asterisk#

Starting a session

The CLI can be accessed by logging in to the Asterisk server’s command line interface using a terminal or SSH client. Typically, you would run the command asterisk -r or asterisk -vvvvr or asterisk -c to start an interactive session with the Asterisk CLI.

Note:
The number of ‘v’s (e.g., -vvvvvvvv) in the -vvvvvvvvr option represents the verbosity level, with each ‘v’ increasing the verbosity. The more ‘v’s you include, the more detailed information you will see in the CLI output.

The asterisk -c provides a basic level of verbosity and console log messages, while asterisk -vvvvvvvvr offers high verbosity and extensive debug information. The latter is typically used for in-depth troubleshooting and debugging scenarios where detailed insights into the system’s operation are required.

In cases where there’s a crash and asterisk -vvvvvvr does not fire the CLI. you may want to use asterisk -g to first Dump core before retrying with asterisk -vvvvvvr

Ending a Session

On the asterisk CLI, the command core stop gracefully is used to gracefully stop the Asterisk service. When you execute this command, Asterisk will initiate a controlled shutdown process, allowing active calls and ongoing operations to complete before shutting down.

The command core stop now forces an immediate shutdown of the Asterisk service. It terminates ongoing calls and operations abruptly without allowing them to complete. This command should be used with caution, as it may result in call disruptions or data loss.

Table of Contents